aboutsummaryrefslogtreecommitdiff
path: root/web/logging.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-15 19:14:29 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-15 19:14:29 +0200
commitc2f3b1c9c534cadc81ebab3e718832d121cdf9cf (patch)
tree458552dfe2e114e4d6dd9aae766855dc6351efbb /web/logging.h
parent97ae34da2a51d9bbc13905598ebc80633c3f80c2 (diff)
downloadnissy-core-c2f3b1c9c534cadc81ebab3e718832d121cdf9cf.tar.gz
nissy-core-c2f3b1c9c534cadc81ebab3e718832d121cdf9cf.zip
WASM and JS port - work in progress
Diffstat (limited to '')
-rw-r--r--web/logging.h37
1 files changed, 37 insertions, 0 deletions
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 @@
1#ifndef LOGGING_H
2#define LOGGING_H
3
4#include "../cpp/nissy.h"
5#include <emscripten/bind.h>
6#include <string>
7
8#define LOGGING_EMBIND \
9 emscripten::function("addCallbackFunction", &addCallbackFunction);
10
11extern "C" {
12 extern int addCallbackFunction();
13 extern void callFunction(int, const char *);
14}
15
16static int logger_id = -1;
17
18void log(std::string s)
19{
20 if (logger_id == -1)
21 return;
22
23 callFunction(logger_id, s.c_str());
24}
25
26void log_wrapper(const char *cstr, void *data)
27{
28 log(cstr);
29}
30
31void set_logger(int id)
32{
33 logger_id = id;
34 nissy::set_logger(log_wrapper, NULL);
35}
36
37#endif

Generated with cgit - Back to sebastiano.tronto.net