From c2dec7029251d64692d14da800c02200ac621346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 11 Dec 2016 14:34:45 -0500 Subject: basic/log: merge two big log_struct_internal invocations into one We can take advantage of the fact a NULL argument terminates the list. --- src/basic/log.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'src/basic') diff --git a/src/basic/log.c b/src/basic/log.c index f5cff4cc9f..9febe391ac 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1134,8 +1134,8 @@ int log_syntax_internal( PROTECT_ERRNO; char buffer[LINE_MAX]; - int r; va_list ap; + const char *unit_fmt = NULL; if (error < 0) error = -error; @@ -1154,24 +1154,15 @@ int log_syntax_internal( va_end(ap); if (unit) - r = log_struct_internal( - level, error, - file, line, func, - getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, - LOG_MESSAGE_ID(SD_MESSAGE_INVALID_CONFIGURATION), - "CONFIG_FILE=%s", config_file, - "CONFIG_LINE=%u", config_line, - LOG_MESSAGE("[%s:%u] %s", config_file, config_line, buffer), - NULL); - else - r = log_struct_internal( - level, error, - file, line, func, - LOG_MESSAGE_ID(SD_MESSAGE_INVALID_CONFIGURATION), - "CONFIG_FILE=%s", config_file, - "CONFIG_LINE=%u", config_line, - LOG_MESSAGE("[%s:%u] %s", config_file, config_line, buffer), - NULL); - - return r; + unit_fmt = getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s"; + + return log_struct_internal( + level, error, + file, line, func, + LOG_MESSAGE_ID(SD_MESSAGE_INVALID_CONFIGURATION), + "CONFIG_FILE=%s", config_file, + "CONFIG_LINE=%u", config_line, + LOG_MESSAGE("[%s:%u] %s", config_file, config_line, buffer), + unit_fmt, unit, + NULL); } -- cgit v1.2.1 From e697dfef649ecc077e160a077f86a06f1a1ee8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 11 Dec 2016 14:37:12 -0500 Subject: share/log: change log_syntax from "[a:b] " to "a:b: " MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those square brackets don't fit how our other messages look like; we use colons everywhere else. The "[a:b]" format was originally added in ed5bcfbe3c3b68e59242c03649eea03a9707d318, and remained unchanged for 7 years, but in the meantime other conventions evolved. The new version is also one character shorter. [/etc/systemd/system/systemd-networkd.service.d/override.conf:2] Failed to parse sec value, ignoring: ... ↓ /etc/systemd/system/systemd-networkd.service.d/override.conf:2: Failed to parse sec value, ignoring: ... --- src/basic/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/basic') diff --git a/src/basic/log.c b/src/basic/log.c index 9febe391ac..4af4d55b33 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1162,7 +1162,7 @@ int log_syntax_internal( LOG_MESSAGE_ID(SD_MESSAGE_INVALID_CONFIGURATION), "CONFIG_FILE=%s", config_file, "CONFIG_LINE=%u", config_line, - LOG_MESSAGE("[%s:%u] %s", config_file, config_line, buffer), + LOG_MESSAGE("%s:%u: %s", config_file, config_line, buffer), unit_fmt, unit, NULL); } -- cgit v1.2.1 From b457b33ddc4f25b51880b5c2d575cc61fa14faf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 11 Dec 2016 15:40:55 -0500 Subject: =?UTF-8?q?basic/log:=20CODE=5FFUNCTION=20=E2=86=92=20CODE=5FFUNC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit systemd.journal-fields(7) documents CODE_FUNC=. Internally, we were inconsistent: sd_journal_print uses CODE_FUNC=, log.h has CODE_FUNCTION=, python-systemd and bootchart also used CODE_FUNC=, when they were internal. Most external projects use sd_journal_* functions, so CODE_FUNC=, python-systemd still uses CODE_FUNC=, as does systemd-bootchart, and independent reimplementations in golang-github-coreos-go-systemd, qtbase, network manager, glib, pulseaudio. Hence, I don't think there's much choice. --- src/basic/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/basic') diff --git a/src/basic/log.c b/src/basic/log.c index 4af4d55b33..71d5a0baa2 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -500,7 +500,7 @@ static int log_do_header( line ? "CODE_LINE=" : "", line ? 1 : 0, line, /* %.0d means no output too, special case for 0 */ line ? "\n" : "", - isempty(func) ? "" : "CODE_FUNCTION=", + isempty(func) ? "" : "CODE_FUNC=", isempty(func) ? "" : func, isempty(func) ? "" : "\n", error ? "ERRNO=" : "", -- cgit v1.2.1