summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukáš Ježek <lukas.jezek@nic.cz>2021-07-21 11:40:29 +0200
committerTomas Krizek <tomas.krizek@nic.cz>2021-07-29 11:42:34 +0200
commit40c6e1369770df4e10787b3fa176309fd09529b4 (patch)
treef4122b172d56720adc51df891b4a1abf7c377d37 /lib
parentlib/utils: drop a pair of unused macros (diff)
downloadknot-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.c1
-rw-r--r--lib/log.h6
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/log.c b/lib/log.c
index d03158aa..1d02b2e3 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -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 },
};
diff --git a/lib/log.h b/lib/log.h
index 72e0f591..9d254084 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -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)