From c2f3b1c9c534cadc81ebab3e718832d121cdf9cf Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 15 May 2025 19:14:29 +0200 Subject: WASM and JS port - work in progress --- web/logging.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 web/logging.h (limited to 'web/logging.h') diff --git a/web/logging.h b/web/logging.h new file mode 100644 index 0000000..b20a595 --- /dev/null +++ b/web/logging.h @@ -0,0 +1,37 @@ +#ifndef LOGGING_H +#define LOGGING_H + +#include "../cpp/nissy.h" +#include +#include + +#define LOGGING_EMBIND \ + emscripten::function("addCallbackFunction", &addCallbackFunction); + +extern "C" { + extern int addCallbackFunction(); + extern void callFunction(int, const char *); +} + +static int logger_id = -1; + +void log(std::string s) +{ + if (logger_id == -1) + return; + + callFunction(logger_id, s.c_str()); +} + +void log_wrapper(const char *cstr, void *data) +{ + log(cstr); +} + +void set_logger(int id) +{ + logger_id = id; + nissy::set_logger(log_wrapper, NULL); +} + +#endif -- cgit v1.3