Add interface for changing ggwave's internal logging (#52)

* ggwave : add interface for changing ggwave's internal logging

Using GGWave::setLogFile() it is now possible to change the log file
used internally by ggwave, or disable it all together.

* ggwave : add comments about thread-safety of setLogFile
This commit is contained in:
Georgi Gerganov
2021-09-21 06:48:16 +03:00
committed by GitHub
parent 1a0af88ed6
commit 9cf2d476b8
3 changed files with 62 additions and 20 deletions

View File

@@ -90,6 +90,23 @@ extern "C" {
// the python module and unfortunately had to do it this way
typedef int ggwave_Instance;
// Change file stream for internal ggwave logging. NULL - disable logging
//
// Intentionally passing it as void * instead of FILE * to avoid including a header
//
// // log to standard error
// ggwave_setLogFile(stderr);
//
// // log to standard output
// ggwave_setLogFile(stdout);
//
// // disable logging
// ggwave_setLogFile(NULL);
//
// Note: not thread-safe. Do not call while any GGWave instances are running
//
GGWAVE_API void ggwave_setLogFile(void * fptr);
// Helper method to get default instance parameters
GGWAVE_API ggwave_Parameters ggwave_getDefaultParameters(void);
@@ -306,6 +323,15 @@ public:
GGWave(const Parameters & parameters);
~GGWave();
// set file stream for the internal ggwave logging
//
// By default, ggwave prints internal log messages to stderr.
// To disable logging all together, call this method with nullptr.
//
// Note: not thread-safe. Do not call while any GGWave instances are running
//
static void setLogFile(FILE * fptr);
static const Parameters & getDefaultParameters();
// set Tx data to encode