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