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. --- tools/tool.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'tools/tool.h') diff --git a/tools/tool.h b/tools/tool.h index 51301c6..ee6c8eb 100644 --- a/tools/tool.h +++ b/tools/tool.h @@ -9,8 +9,7 @@ #include "../src/nissy.h" #include "nissy_extra.h" -static void log_stderr(const char *); -static void log_stdout(const char *); +static void log_stdout(const char *, void *); static double timerun(void (*)(void)); static void writetable(const char *, int64_t, const char *); static long long int generatetable(const char *, char **, @@ -23,13 +22,7 @@ static void derivedata_run( const char *, const char *, const char *, const char *); static void -log_stderr(const char *str) -{ - fprintf(stderr, "%s", str); -} - -static void -write_stdout(const char *str) +log_stdout(const char *str, void *unused) { fprintf(stdout, "%s", str); } @@ -211,7 +204,7 @@ gendata_run( case -2: goto gendata_run_finish; default: - nissy_datainfo(size, buf, write_stdout); + nissy_datainfo(size, buf); printf("\n"); printf("Succesfully generated %lld bytes. " "See above for details on the tables.\n", size); @@ -244,7 +237,7 @@ derivedata_run( case -2: goto derivedata_run_finish; default: - nissy_datainfo(size, buf, write_stdout); + nissy_datainfo(size, buf); printf("\n"); printf("Succesfully generated %lld bytes. " "See above for details on the tables.\n", size); -- cgit v1.3