diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-15 15:51:40 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-15 15:51:40 +0200 |
| commit | b25a939e2d8b045c083caf3264c4e5aac1cf88fb (patch) | |
| tree | 37b862c82389ceddcf4624b5e26536390d6b8265 /src/nissy.h | |
| parent | b02c083a3545b6e6b36ab62680128edec619a804 (diff) | |
| download | nissy-core-b25a939e2d8b045c083caf3264c4e5aac1cf88fb.tar.gz nissy-core-b25a939e2d8b045c083caf3264c4e5aac1cf88fb.zip | |
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.
Diffstat (limited to '')
| -rw-r--r-- | src/nissy.h | 9 |
1 files changed, 7 insertions, 2 deletions
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 | |||
| 421 | disables logging. | 421 | disables logging. |
| 422 | 422 | ||
| 423 | Parameters: | 423 | Parameters: |
| 424 | write - A callback writer with the same signature as printf(3). | 424 | logger_function - A pointer to a function that takes two parameters: |
| 425 | * A C string, the string to be printed. | ||
| 426 | * Any other data via a void pointer. | ||
| 427 | user_data - Any data that will be provided by the logger when | ||
| 428 | calling logger_function. | ||
| 425 | 429 | ||
| 426 | Return values: | 430 | Return values: |
| 427 | NISSY_OK - Logger set succesfully. No warning or error is going to be given | 431 | NISSY_OK - Logger set succesfully. No warning or error is going to be given |
| @@ -429,5 +433,6 @@ Return values: | |||
| 429 | */ | 433 | */ |
| 430 | long long | 434 | long long |
| 431 | nissy_setlogger( | 435 | nissy_setlogger( |
| 432 | void (*logger_function)(const char *) | 436 | void (*logger_function)(const char *, void *), |
| 437 | void *user_data | ||
| 433 | ); | 438 | ); |
