summaryrefslogtreecommitdiff
path: root/include/qntan
diff options
context:
space:
mode:
authorAndreas Fankhauser hiddenalpha.ch2026-03-28 19:39:52 +0100
committerAndreas Fankhauser hiddenalpha.ch2026-03-28 19:39:52 +0100
commit0fe48c879f7fbb70a6d047bc6bc2a21d5f252c18 (patch)
treec5ceed7d53ac288a98311b869e09dc68ffe45581 /include/qntan
parent9d57dcd4eff4c851669252631dd2b8adccc923a5 (diff)
downloadQntan-0fe48c879f7fbb70a6d047bc6bc2a21d5f252c18.tar.gz
Qntan-0fe48c879f7fbb70a6d047bc6bc2a21d5f252c18.zip
Extend `Logger` API a bit.
- Introduce `isXxxOn()` funcs to check if log level is on. - Introduce `Qntan_Logger_xxxx()` macros for better overall API consistency through the library.
Diffstat (limited to 'include/qntan')
-rw-r--r--include/qntan/Qntan.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/qntan/Qntan.h b/include/qntan/Qntan.h
index 580b280..9232817 100644
--- a/include/qntan/Qntan.h
+++ b/include/qntan/Qntan.h
@@ -271,12 +271,52 @@ struct Qntan_Scheduler {
+#ifndef Qntan_Logger_fatal
+# define Qntan_Logger_fatal(A, ...) do{if(A){(*(A))->fatal(A, __VA_ARGS__);}}while(0)
+#endif
+#ifndef Qntan_Logger_error
+# define Qntan_Logger_error(A, ...) do{if(A){(*(A))->error(A, __VA_ARGS__);}}while(0)
+#endif
+#ifndef Qntan_Logger_warn
+# define Qntan_Logger_warn(A, ...) do{if(A){(*(A))->warn(A, __VA_ARGS__);}}while(0)
+#endif
+#ifndef Qntan_Logger_info
+# define Qntan_Logger_info(A, ...) do{if(A){(*(A))->info(A, __VA_ARGS__);}}while(0)
+#endif
+#ifndef Qntan_Logger_debug
+# define Qntan_Logger_debug(A, ...) do{if(A){(*(A))->debug(A, __VA_ARGS__);}}while(0)
+#endif
+#ifndef Qntan_Logger_trace
+# define Qntan_Logger_trace(A, ...) do{if(A){(*(A))->trace(A, __VA_ARGS__);}}while(0)
+#endif
+#ifndef Qntan_Logger_isFatalOn
+# define Qntan_Logger_isFatalOn(A) ((A) && (*(A))->isFatalOn(A))
+#endif
+#ifndef Qntan_Logger_isErrorOn
+# define Qntan_Logger_isErrorOn(A) ((A) && (*(A))->isErrorOn(A))
+#endif
+#ifndef Qntan_Logger_isWarnOn
+# define Qntan_Logger_isWarnOn(A) ((A) && (*(A))->isWarnOn(A))
+#endif
+#ifndef Qntan_Logger_isInfoOn
+# define Qntan_Logger_isInfoOn(A) ((A) && (*(A))->isInfoOn(A))
+#endif
+#ifndef Qntan_Logger_isDebugOn
+# define Qntan_Logger_isDebugOn(A) ((A) && (*(A))->isDebugOn(A))
+#endif
+#ifndef Qntan_Logger_isTraceOn
+# define Qntan_Logger_isTraceOn(A) ((A) && (*(A))->isTraceOn(A))
+#endif
+
struct Qntan_Logger {
/* Logger impls MUST prefer format specifiers that are specified in
* POSIX stdio printf family of functions.
* Logger impls SHOULD NOT implement format specifiers that could be
* confused by standard specifiers specified by stdio printf and
* related APIs.
+ * This API also got inspiration from "http://slf4j.org/". So you
+ * might find useful documentation there, even slf4j is made for
+ * Java.
*/
void (*fatal)( struct Qntan_Logger**, char const*fmt, ...);
/**/
@@ -290,6 +330,18 @@ struct Qntan_Logger {
/**/
void (*trace)( struct Qntan_Logger**, char const*fmt, ...);
/**/
+ int (*isFatalOn)( struct Qntan_Logger** );
+ /**/
+ int (*isErrorOn)( struct Qntan_Logger** );
+ /**/
+ int (*isWarnOn)( struct Qntan_Logger** );
+ /**/
+ int (*isInfoOn)( struct Qntan_Logger** );
+ /**/
+ int (*isDebugOn)( struct Qntan_Logger** );
+ /**/
+ int (*isTraceOn)( struct Qntan_Logger** );
+ /**/
};