diff options
author | Lukáš Ježek <lukas.jezek@nic.cz> | 2021-07-21 11:40:29 +0200 |
---|---|---|
committer | Tomas Krizek <tomas.krizek@nic.cz> | 2021-07-29 11:42:34 +0200 |
commit | 40c6e1369770df4e10787b3fa176309fd09529b4 (patch) | |
tree | f4122b172d56720adc51df891b4a1abf7c377d37 /lib | |
parent | lib/utils: drop a pair of unused macros (diff) | |
download | knot-resolver-40c6e1369770df4e10787b3fa176309fd09529b4.tar.xz knot-resolver-40c6e1369770df4e10787b3fa176309fd09529b4.zip |
log: add log functions and LOG_GRP_MODULE group for users's modules
logging
Diffstat (limited to 'lib')
-rw-r--r-- | lib/log.c | 1 | ||||
-rw-r--r-- | lib/log.h | 6 |
2 files changed, 7 insertions, 0 deletions
@@ -71,6 +71,7 @@ log_group_names_t log_group_names[] = { GRP_NAME_ITEM(LOG_GRP_DOTAUTH), GRP_NAME_ITEM(LOG_GRP_HTTP), GRP_NAME_ITEM(LOG_GRP_CONTROL), + GRP_NAME_ITEM(LOG_GRP_MODULE), GRP_NAME_ITEM(LOG_GRP_DEVEL), { NULL, -1 }, }; @@ -67,6 +67,7 @@ enum kr_log_group { LOG_GRP_DOTAUTH, LOG_GRP_HTTP, LOG_GRP_CONTROL, + LOG_GRP_MODULE, /* ^^ Add new log groups above ^^. */ LOG_GRP_DEVEL, /* Must be last entry in enum! */ }; @@ -118,6 +119,7 @@ typedef struct { #define LOG_GRP_DOTAUTH_TAG "dotaut" #define LOG_GRP_HTTP_TAG "http" #define LOG_GRP_CONTROL_TAG "contrl" +#define LOG_GRP_MODULE_TAG "module" #define LOG_GRP_DEVEL_TAG "devel" KR_EXPORT @@ -175,6 +177,10 @@ void kr_log_init(log_level_t level, log_target_t target); #define kr_log_deprecate(grp, fmt, ...) \ kr_log_fmt(LOG_GRP_ ## grp, LOG_WARNING,SD_JOURNAL_METADATA, \ "[%-6s] deprecation WARNING: " fmt, LOG_GRP_ ## grp ## _TAG, ## __VA_ARGS__) +#define kr_log(fmt, ...) \ + kr_log_fmt(LOG_GRP_MODULE, LOG_INFO, SD_JOURNAL_METADATA, \ + "[%-6s] " fmt, LOG_GRP_MODULE_TAG, ## __VA_ARGS__) + #define KR_LOG_LEVEL_IS(exp) ((kr_log_level >= (exp)) ? true : false) |