diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-21 00:58:13 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-21 00:58:13 +0100 |
| commit | 3d48d8d62349ba4b66dc4bc5c3582486baa872d6 (patch) | |
| tree | 8fc01a8185be93b3ca381c8d5c3c50e4d002af3e | |
| parent | 1d793c34b036cd094369ae56f15f5731b03c5bee (diff) | |
Add global log level
| -rw-r--r-- | any_log.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -99,6 +99,8 @@ typedef enum { #define ANY_LOG_ATTRIBUTE(...) #endif +extern any_log_level_t any_log_level; + extern const char *any_log_level_strings[ANY_LOG_ALL]; ANY_LOG_ATTRIBUTE(pure) @@ -123,6 +125,12 @@ void any_log_format(any_log_level_t level, const char *module, #include <stdlib.h> #include <string.h> +#ifndef ANY_LOG_DEFAULT_LEVEL +#define ANY_LOG_DEFAULT_LEVEL ANY_LOG_INFO +#endif + +any_log_level_t any_log_level = ANY_LOG_DEFAULT_LEVEL; + #ifndef ANY_LOG_PANIC_STRING #define ANY_LOG_PANIC_STRING "panic" #endif @@ -201,6 +209,9 @@ void any_log_exit(const char *module, const char *func) void any_log_format(any_log_level_t level, const char *module, const char *func, const char *format, ...) { + if (level > any_log_level) + return; + fprintf(stdout, ANY_LOG_FORMAT_BEFORE(level, module, func)); va_list args; |
