summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-01 16:37:10 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-04 10:36:24 +0200
commitbdc3426870be2536dd807692420b7b86e7d76ab7 (patch)
tree1e4a601308b6d981b0a454204e16715327e3e1f6 /src/basic
parentudev: warn when we fail to parse udev.conf (diff)
downloadsystemd-bdc3426870be2536dd807692420b7b86e7d76ab7.tar.xz
systemd-bdc3426870be2536dd807692420b7b86e7d76ab7.zip
basic/log: omit ":0" from message when line number is not specified
And obviously CONFIG_LINE=0 is also not logged. The way that log_syntax_internal now looks is becoming a bit crazy, but we can't easily conditionalize on both unit and config_file, and we have different types, so it's not easy to make this more compact.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/log.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index 6648633f97..a30ffb9d87 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -1238,18 +1238,29 @@ int log_syntax_internal(
if (unit)
unit_fmt = getpid_cached() == 1 ? "UNIT=%s" : "USER_UNIT=%s";
- if (config_file)
- return log_struct_internal(
- LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
- error,
- file, line, func,
- "MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
- "CONFIG_FILE=%s", config_file,
- "CONFIG_LINE=%u", config_line,
- LOG_MESSAGE("%s:%u: %s", config_file, config_line, buffer),
- unit_fmt, unit,
- NULL);
- else if (unit)
+ if (config_file) {
+ if (config_line > 0)
+ return log_struct_internal(
+ LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
+ error,
+ file, line, func,
+ "MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
+ "CONFIG_FILE=%s", config_file,
+ "CONFIG_LINE=%u", config_line,
+ LOG_MESSAGE("%s:%u: %s", config_file, config_line, buffer),
+ unit_fmt, unit,
+ NULL);
+ else
+ return log_struct_internal(
+ LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
+ error,
+ file, line, func,
+ "MESSAGE_ID=" SD_MESSAGE_INVALID_CONFIGURATION_STR,
+ "CONFIG_FILE=%s", config_file,
+ LOG_MESSAGE("%s: %s", config_file, buffer),
+ unit_fmt, unit,
+ NULL);
+ } else if (unit)
return log_struct_internal(
LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level),
error,