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. --- src/nissy.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/nissy.h') diff --git a/src/nissy.h b/src/nissy.h index 816e03a..b13f417 100644 --- a/src/nissy.h +++ b/src/nissy.h @@ -421,7 +421,11 @@ Set a global logger function used by this library. Setting the logger to NULL disables logging. Parameters: - write - A callback writer with the same signature as printf(3). + logger_function - A pointer to a function that takes two parameters: + * A C string, the string to be printed. + * Any other data via a void pointer. + user_data - Any data that will be provided by the logger when + calling logger_function. Return values: NISSY_OK - Logger set succesfully. No warning or error is going to be given @@ -429,5 +433,6 @@ Return values: */ long long nissy_setlogger( - void (*logger_function)(const char *) + void (*logger_function)(const char *, void *), + void *user_data ); -- cgit v1.3