From 5584ce95db40743acec582a59c4efccd3c33d59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Mon, 10 Jul 2023 12:40:18 +0200 Subject: [PATCH] log: Detect newlines in Python log output So that Python messages are annotated with timestamps too (if -t was passed). --- kernel/log.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/log.cc b/kernel/log.cc index 985165a97..12d7596a1 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -147,6 +147,12 @@ void logv(const char *format, va_list ap) if (format[0] && format[strlen(format)-1] == '\n') next_print_log = true; + // Special case to detect newlines in Python log output, since + // the binding always calls `log("%s", payload)` and the newline + // is then in the first formatted argument + if (!strcmp(format, "%s") && str.back() == '\n') + next_print_log = true; + for (auto f : log_files) fputs(time_str.c_str(), f);