logging.h (431B)
1 static void (*js_log)(const char *) = nullptr; 2 3 void log(std::string s) 4 { 5 if (js_log != nullptr) 6 js_log(s.c_str()); 7 } 8 9 void log_wrapper(const char *cstr, void *data) 10 { 11 log(cstr); 12 } 13 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) 19 { 20 js_log = (void (*)(const char *))f; 21 nissy::set_logger(log_wrapper, NULL); 22 }