aboutsummaryrefslogtreecommitdiff
path: root/web/logging.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-06-05 08:37:34 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-06-05 08:37:34 +0200
commit52c74a1c33ce12b93ec5830f5a6348d9578c7c6e (patch)
treee763fa21a5bc057b36a42af8caa9766bb1cfd8b3 /web/logging.h
parent57f194ef57e393d84e2d3c73115ec528e02ea3c9 (diff)
downloadnissy-core-52c74a1c33ce12b93ec5830f5a6348d9578c7c6e.tar.gz
nissy-core-52c74a1c33ce12b93ec5830f5a6348d9578c7c6e.zip
Simplify callback business (web version)
Diffstat (limited to 'web/logging.h')
-rw-r--r--web/logging.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/web/logging.h b/web/logging.h
index 9ed4835..14609a0 100644
--- a/web/logging.h
+++ b/web/logging.h
@@ -1,11 +1,9 @@
1static int logger_id = -1; 1static void (*js_log)(const char *) = nullptr;
2 2
3void log(std::string s) 3void log(std::string s)
4{ 4{
5 if (logger_id == -1) 5 if (js_log != nullptr)
6 return; 6 js_log(s.c_str());
7
8 callFunction(logger_id, s.c_str());
9} 7}
10 8
11void log_wrapper(const char *cstr, void *data) 9void log_wrapper(const char *cstr, void *data)
@@ -13,8 +11,12 @@ void log_wrapper(const char *cstr, void *data)
13 log(cstr); 11 log(cstr);
14} 12}
15 13
16void set_logger(int id) 14/*
15To receive a function pointer for JS, we use an int parameter.
16This will have to be changed to a 64-bit integer when we move to WASM64.
17*/
18void set_logger(int f)
17{ 19{
18 logger_id = id; 20 js_log = (void (*)(const char *))f;
19 nissy::set_logger(log_wrapper, NULL); 21 nissy::set_logger(log_wrapper, NULL);
20} 22}

Generated with cgit - Back to sebastiano.tronto.net