aboutsummaryrefslogtreecommitdiff
path: root/tools/tool.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-15 15:51:40 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-15 15:51:40 +0200
commitb25a939e2d8b045c083caf3264c4e5aac1cf88fb (patch)
tree37b862c82389ceddcf4624b5e26536390d6b8265 /tools/tool.h
parentb02c083a3545b6e6b36ab62680128edec619a804 (diff)
downloadnissy-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 'tools/tool.h')
-rw-r--r--tools/tool.h15
1 files changed, 4 insertions, 11 deletions
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 @@
9#include "../src/nissy.h" 9#include "../src/nissy.h"
10#include "nissy_extra.h" 10#include "nissy_extra.h"
11 11
12static void log_stderr(const char *); 12static void log_stdout(const char *, void *);
13static void log_stdout(const char *);
14static double timerun(void (*)(void)); 13static double timerun(void (*)(void));
15static void writetable(const char *, int64_t, const char *); 14static void writetable(const char *, int64_t, const char *);
16static long long int generatetable(const char *, char **, 15static long long int generatetable(const char *, char **,
@@ -23,13 +22,7 @@ static void derivedata_run(
23 const char *, const char *, const char *, const char *); 22 const char *, const char *, const char *, const char *);
24 23
25static void 24static void
26log_stderr(const char *str) 25log_stdout(const char *str, void *unused)
27{
28 fprintf(stderr, "%s", str);
29}
30
31static void
32write_stdout(const char *str)
33{ 26{
34 fprintf(stdout, "%s", str); 27 fprintf(stdout, "%s", str);
35} 28}
@@ -211,7 +204,7 @@ gendata_run(
211 case -2: 204 case -2:
212 goto gendata_run_finish; 205 goto gendata_run_finish;
213 default: 206 default:
214 nissy_datainfo(size, buf, write_stdout); 207 nissy_datainfo(size, buf);
215 printf("\n"); 208 printf("\n");
216 printf("Succesfully generated %lld bytes. " 209 printf("Succesfully generated %lld bytes. "
217 "See above for details on the tables.\n", size); 210 "See above for details on the tables.\n", size);
@@ -244,7 +237,7 @@ derivedata_run(
244 case -2: 237 case -2:
245 goto derivedata_run_finish; 238 goto derivedata_run_finish;
246 default: 239 default:
247 nissy_datainfo(size, buf, write_stdout); 240 nissy_datainfo(size, buf);
248 printf("\n"); 241 printf("\n");
249 printf("Succesfully generated %lld bytes. " 242 printf("Succesfully generated %lld bytes. "
250 "See above for details on the tables.\n", size); 243 "See above for details on the tables.\n", size);

Generated with cgit - Back to sebastiano.tronto.net