aboutsummaryrefslogtreecommitdiff
path: root/web/logging.h
blob: b20a595e1261089907968c82a7bbeac7defd73dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef LOGGING_H
#define LOGGING_H

#include "../cpp/nissy.h"
#include <emscripten/bind.h>
#include <string>

#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

Generated with cgit - Back to sebastiano.tronto.net