diff options
Diffstat (limited to 'web/logging.h')
| -rw-r--r-- | web/logging.h | 16 |
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 @@ | |||
| 1 | static int logger_id = -1; | 1 | static void (*js_log)(const char *) = nullptr; |
| 2 | 2 | ||
| 3 | void log(std::string s) | 3 | void 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 | ||
| 11 | void log_wrapper(const char *cstr, void *data) | 9 | void 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 | ||
| 16 | void set_logger(int id) | 14 | /* |
| 15 | To receive a function pointer for JS, we use an int parameter. | ||
| 16 | This will have to be changed to a 64-bit integer when we move to WASM64. | ||
| 17 | */ | ||
| 18 | void 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 | } |
