diff options
author | David Robillard <d@drobilla.net> | 2020-03-14 11:21:53 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-03-14 11:21:53 +0100 |
commit | 554ac923e8973b7496f96e30a56eaaf9d30b6108 (patch) | |
tree | a0a3070325edd6e9f89a6267c2c5fd107cf0ae37 /pugl/pugl.h | |
parent | e09f204aca2393ba0f78867eb2e284ab00091205 (diff) | |
download | pugl-554ac923e8973b7496f96e30a56eaaf9d30b6108.tar.gz pugl-554ac923e8973b7496f96e30a56eaaf9d30b6108.tar.bz2 pugl-554ac923e8973b7496f96e30a56eaaf9d30b6108.zip |
Add logging API
Diffstat (limited to 'pugl/pugl.h')
-rw-r--r-- | pugl/pugl.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h index 718e76a..c5f8969 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -491,6 +491,27 @@ typedef struct PuglWorldImpl PuglWorld; typedef void* PuglWorldHandle; /** + A log message level, compatible with syslog. +*/ +typedef enum { + PUGL_LOG_LEVEL_ERR = 3, ///< Error + PUGL_LOG_LEVEL_WARNING = 4, ///< Warning + PUGL_LOG_LEVEL_INFO = 6, ///< Informational message + PUGL_LOG_LEVEL_DEBUG = 7 ///< Debug message +} PuglLogLevel; + +/** + A function called to report log messages. + + @param world The world that produced this log message. + @param level Log level. + @param msg Message string. +*/ +typedef void (*PuglLogFunc)(PuglWorld* world, + PuglLogLevel level, + const char* msg); + +/** Create a new world. @return A new world, which must be later freed with puglFreeWorld(). @@ -533,6 +554,23 @@ PUGL_API void* puglGetNativeWorld(PuglWorld* world); /** + Set the function to call to log a message. + + This will be called to report any log messages generated internally by Pugl + which are enabled according to the log level. +*/ +PUGL_API PuglStatus +puglSetLogFunc(PuglWorld* world, PuglLogFunc logFunc); + +/** + Set the level of log messages to emit. + + Any log messages with a level less than or equal to `level` will be emitted. +*/ +PUGL_API PuglStatus +puglSetLogLevel(PuglWorld* world, PuglLogLevel level); + +/** Set the class name of the application. This is a stable identifier for the application, used as the window |