aboutsummaryrefslogtreecommitdiff
path: root/web/logging.h
diff options
context:
space:
mode:
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