Commit 00f53b6e authored by Daniel Salzman's avatar Daniel Salzman

log: fix inconsistent zone names in structured logs

fixes #560
parent dd45fb8e
......@@ -216,7 +216,7 @@ static void emit_log_msg(int level, log_source_t src, const char *zone,
if (*src_levels(log, LOG_TARGET_SYSLOG, src) & LOG_MASK(level)) {
#ifdef ENABLE_SYSTEMD
if (use_journal) {
char *zone_fmt = zone ? "ZONE=%.*s" : NULL;
char *zone_fmt = zone ? "ZONE=%.*s." : NULL;
sd_journal_send("PRIORITY=%d", level,
"MESSAGE=%s", msg,
zone_fmt, zone_len, zone,
......@@ -317,9 +317,11 @@ static void log_msg_text(int level, log_source_t src, const char *zone,
size_t zone_len = 0;
if (zone != NULL) {
zone_len = strlen(zone);
const char *trailing_dot = zone[zone_len - 1] == '.' ? "" : ".";
if (zone_len > 0 && zone[zone_len - 1] == '.') {
zone_len--;
}
int ret = log_msg_add(&write, &capacity, "[%.*s%s] ", zone_len, zone, trailing_dot);
int ret = log_msg_add(&write, &capacity, "[%.*s.] ", zone_len, zone);
if (ret != KNOT_EOK) {
rcu_read_unlock();
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment