diff options
author | sanine <sanine.not@pm.me> | 2021-09-25 10:45:36 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2021-09-25 10:45:36 -0500 |
commit | 732aca2a13ebab4f4fb3418b103b91d57e698ccb (patch) | |
tree | 05a89605a1b836c63c44a21c0c8c4f0ad17c8427 /src/logging | |
parent | 78e262b448e034e96aa75193a76d36cd0062daf7 (diff) |
add honey_info() log function
Diffstat (limited to 'src/logging')
-rw-r--r-- | src/logging/logging.c | 9 | ||||
-rw-r--r-- | src/logging/logging.h | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/logging/logging.c b/src/logging/logging.c index 82895d4..2a63a77 100644 --- a/src/logging/logging.c +++ b/src/logging/logging.c @@ -7,7 +7,7 @@ struct honey_log_info_t honey_log_info; -const char * honey_log_level_str() +static const char * honey_log_level_str_(enum honey_log_level_t level) { switch(honey_log_info.log_level) { case DEBUG: @@ -36,6 +36,10 @@ const char * honey_log_level_str() } } +const char * honey_log_level_str() { + return honey_log_level_str_(honey_log_info.log_level); +} + void honey_log_set_level(enum honey_log_level_t level) { @@ -71,7 +75,8 @@ void honey_log(enum honey_log_level_t required_level, if (honey_log_info.log_level >= required_level) { va_list args; va_start(args, fmt); - fprintf(honey_log_info.log_file, prefix); + fprintf(honey_log_info.log_file, "%-8s", + prefix); vfprintf(honey_log_info.log_file, fmt, args); va_end(args); } diff --git a/src/logging/logging.h b/src/logging/logging.h index 6589533..2d50b67 100644 --- a/src/logging/logging.h +++ b/src/logging/logging.h @@ -15,6 +15,7 @@ extern struct honey_log_info_t honey_log_info; const char * honey_log_level_str(); + void honey_log_set_level(enum honey_log_level_t level); enum honey_log_level_t honey_log_get_level(); @@ -25,6 +26,7 @@ void honey_log(enum honey_log_level_t required_level, const char *prefix, const char *fmt, ...); -#define honey_debug(...) honey_log(DEBUG, "[DEBUG] ", __VA_ARGS__) +#define honey_debug(...) honey_log(DEBUG, "[DEBUG]", __VA_ARGS__) +#define honey_info(...) honey_log(INFO, "[INFO]", __VA_ARGS__) #endif |