From b25a939e2d8b045c083caf3264c4e5aac1cf88fb Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 15 Apr 2025 15:51:40 +0200 Subject: Better logging function Now it is possible to provide some data together with the logging function. This is useful for example in C++, where I can now provide an arbitrary callable object as data, and a simple wrapper function that call the callable object as logging function. --- cpp/nissy.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cpp/nissy.cpp') diff --git a/cpp/nissy.cpp b/cpp/nissy.cpp index 2a52ab1..944944b 100644 --- a/cpp/nissy.cpp +++ b/cpp/nissy.cpp @@ -24,7 +24,7 @@ extern "C" { unsigned, unsigned, int, int, unsigned long long, const char *, unsigned, char *, long long *); long long nissy_countmoves(const char *); - long long nissy_setlogger(void (*)(const char *)); + long long nissy_setlogger(void (*)(const char *, void *), void *); } namespace nissy { @@ -227,5 +227,8 @@ namespace nissy { return error{err}; } - void set_logger(void (*log)(const char *)) { nissy_setlogger(log); } + void set_logger(void (*log)(const char *, void *), void *data) + { + nissy_setlogger(log, data); + } } -- cgit v1.3