diff options
author | 2023-02-27 16:41:14 +0100 | |
---|---|---|
committer | 2023-02-27 16:41:14 +0100 | |
commit | a4308d5f133e67c2292578277c7a8cb3af790fd5 (patch) | |
tree | 629ff219ad6c219e1ea10c9278a84b4887c43b02 | |
parent | 46e6caba601648c8002bf3e6498b650b79da9611 (diff) | |
download | log-a4308d5f133e67c2292578277c7a8cb3af790fd5.tar.gz log-a4308d5f133e67c2292578277c7a8cb3af790fd5.zip |
Add NONE level
It's used to disable logs for a specific tag.
-rw-r--r-- | src/log.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -7,10 +7,11 @@ #include "log.h" -#define DBG_LVL 0 -#define INF_LVL 1 -#define WRN_LVL 2 -#define ERR_LVL 3 +#define NNN_LVL -1 /* NONE LEVEL */ +#define DBG_LVL 0 +#define INF_LVL 1 +#define WRN_LVL 2 +#define ERR_LVL 3 #define BUFF_SIZE 256 #define HALF_SIZE (BUFF_SIZE / 2 - 1) @@ -54,6 +55,7 @@ check_term_colors() static int log_parse_level_property(char *str_level) { + if (strcmp( str_level, "NONE" ) == 0) return NNN_LVL; if (strcmp( str_level, "DEBUG" ) == 0) return DBG_LVL; if (strcmp( str_level, "INFO" ) == 0) return INF_LVL; if (strcmp( str_level, "WARNING" ) == 0) return WRN_LVL; @@ -176,6 +178,9 @@ print_log(Log *log, int level, char *msg) struct tm *date; const char *lvl; + /* NONE level. Disable log */ + if (log->level == NNN_LVL) return; + /* Don't display log if the choosen level is major. * For example: log->level is ERROR and level is INFO, only ERROR logs will be shown. */ if (log->level > level) return; |