From 577a0fd59bf8fdf533bc8d120e350fe8a3f040bf Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 6 Feb 2023 22:49:35 +0900 Subject: [PATCH 1/2] test: use notice log level to make easily filter out logs from PID1 --- test/testsuite-04.units/logs-filtering.service | 1 + test/units/testsuite-04.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testsuite-04.units/logs-filtering.service b/test/testsuite-04.units/logs-filtering.service index fc89021ca9..06210868fd 100644 --- a/test/testsuite-04.units/logs-filtering.service +++ b/test/testsuite-04.units/logs-filtering.service @@ -3,3 +3,4 @@ Description=Log filtering unit [Service] ExecStart=sh -c 'while true; do echo "Logging from the service, and ~more~"; sleep .25; done' +SyslogLevel=notice diff --git a/test/units/testsuite-04.sh b/test/units/testsuite-04.sh index 2874fc778f..d10a9afbf7 100755 --- a/test/units/testsuite-04.sh +++ b/test/units/testsuite-04.sh @@ -199,7 +199,7 @@ function run_service_and_fetch_logs() { journalctl --sync END=$(date '+%Y-%m-%d %T.%6N') - journalctl -q -u "$UNIT" -S "$START" -U "$END" | grep -Pv "systemd\[[0-9]+\]" + journalctl -q -u "$UNIT" -S "$START" -U "$END" -p notice systemctl stop "$UNIT" } From dd15e4cb57129b915e01495e113696bfe0b70214 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 3 Feb 2023 18:29:36 +0900 Subject: [PATCH 2/2] argv-util: also update program_invocation_short_name Our logging uses program_invocation_short_name. Without this patch, logs from forked client may become broken; spuriously truncated or the short invocation name is not completely shown in the log. --- src/basic/argv-util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/basic/argv-util.c b/src/basic/argv-util.c index b8c371ede5..6c88dcc2ee 100644 --- a/src/basic/argv-util.c +++ b/src/basic/argv-util.c @@ -192,6 +192,10 @@ int rename_process(const char name[]) { strncpy(program_invocation_name, name, k); if (l > k) truncated = true; + + /* Also update the short name. */ + char *p = strrchr(program_invocation_name, '/'); + program_invocation_short_name = p ? p + 1 : program_invocation_name; } /* Third step, completely replace the argv[] array the kernel maintains for us. This requires privileges, but