diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-07-11 00:00:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-11 00:00:34 +0200 |
commit | 08945b59d1f6825c4e7500093db5226766acf620 (patch) | |
tree | b8bccd30faae3e155a86d5c3679cc9af65e4f971 /src/basic/log.c | |
parent | Merge pull request #13009 from keszybz/efi-feature-xbootldr (diff) | |
parent | shared/logs-show: urlify CONFIG_FILE in verbose mode (diff) | |
download | systemd-08945b59d1f6825c4e7500093db5226766acf620.tar.xz systemd-08945b59d1f6825c4e7500093db5226766acf620.zip |
Merge pull request #12926 from keszybz/urlify-logs
Urlify CONFIG_FILE and improve SYSTEMD_LOG_LOCATION
Diffstat (limited to 'src/basic/log.c')
-rw-r--r-- | src/basic/log.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index c484ff57f6..31ecbd1d1b 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -351,7 +351,13 @@ static int write_to_console( get_log_colors(LOG_PRI(level), &on, &off, NULL); if (show_location) { - (void) snprintf(location, sizeof location, "(%s:%i) ", file, line); + const char *lon = "", *loff = ""; + if (show_color) { + lon = ANSI_HIGHLIGHT_YELLOW4; + loff = ANSI_NORMAL; + } + + (void) snprintf(location, sizeof location, "%s%s:%i%s: ", lon, file, line, loff); iovec[n++] = IOVEC_MAKE_STRING(location); } @@ -1232,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, |