nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

logging.h (588B)


      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 
     11 extern "C" {
     12 	extern int addCallbackFunction();
     13 	extern void callFunction(int, const char *);
     14 }
     15 
     16 static int logger_id = -1;
     17 
     18 void log(std::string s)
     19 {
     20 	if (logger_id == -1)
     21 		return;
     22 
     23 	callFunction(logger_id, s.c_str());
     24 }
     25 
     26 void log_wrapper(const char *cstr, void *data)
     27 {
     28 	log(cstr);
     29 }
     30 
     31 void set_logger(int id)
     32 {
     33 	logger_id = id;
     34 	nissy::set_logger(log_wrapper, NULL);
     35 }
     36 
     37 #endif