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 /python/nissy_module.c | |
| 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-- | python/nissy_module.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/python/nissy_module.c b/python/nissy_module.c index da0b1c5..e92cfd9 100644 --- a/python/nissy_module.c +++ b/python/nissy_module.c | |||
| @@ -421,7 +421,7 @@ static struct PyModuleDef nissy_python_module = { | |||
| 421 | }; | 421 | }; |
| 422 | 422 | ||
| 423 | static void | 423 | static void |
| 424 | log_stdout(const char *str) | 424 | log_stdout(const char *str, void *unused) |
| 425 | { | 425 | { |
| 426 | fprintf(stderr, "%s", str); | 426 | fprintf(stderr, "%s", str); |
| 427 | } | 427 | } |
| @@ -429,7 +429,7 @@ log_stdout(const char *str) | |||
| 429 | PyMODINIT_FUNC PyInit_nissy_python_module(void) { | 429 | PyMODINIT_FUNC PyInit_nissy_python_module(void) { |
| 430 | PyObject *module; | 430 | PyObject *module; |
| 431 | 431 | ||
| 432 | nissy_setlogger(log_stdout); | 432 | nissy_setlogger(log_stdout, NULL); |
| 433 | module = PyModule_Create(&nissy_python_module); | 433 | module = PyModule_Create(&nissy_python_module); |
| 434 | 434 | ||
| 435 | PyModule_AddStringConstant(module, "solved_cube", NISSY_SOLVED_CUBE); | 435 | PyModule_AddStringConstant(module, "solved_cube", NISSY_SOLVED_CUBE); |
