From: Lennart Poettering Date: Tue, 29 Sep 2020 11:07:07 +0000 (+0200) Subject: log: include TID= field in structred log output X-Git-Tag: v247-rc1~148^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38ffc7d18aa05c2be6bd3d26fdcd8efbb9bab255;p=thirdparty%2Fsystemd.git log: include TID= field in structred log output It always was the intention to expose this as trusted field _TID=, i.e. automatically determine it from journald via some SCM_xyz field or so, but this is never happened, and it's unlikely this will be added anytime soon to the kernel either, hence let's just generate this sender side, even if it means it's untrusted. --- diff --git a/man/systemd.journal-fields.xml b/man/systemd.journal-fields.xml index 197a468f25d..31e3d8b210b 100644 --- a/man/systemd.journal-fields.xml +++ b/man/systemd.journal-fields.xml @@ -149,6 +149,13 @@ file:/, man: or info: URL. + + + TID= + + The numeric thread ID (TID) the log message originates from. + + diff --git a/src/basic/log.c b/src/basic/log.c index 89d26a4a438..7c68258ea88 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -547,6 +547,7 @@ static int log_do_header( r = snprintf(header, size, "PRIORITY=%i\n" "SYSLOG_FACILITY=%i\n" + "TID=" PID_FMT "\n" "%s%.256s%s" /* CODE_FILE */ "%s%.*i%s" /* CODE_LINE */ "%s%.256s%s" /* CODE_FUNC */ @@ -556,6 +557,7 @@ static int log_do_header( "SYSLOG_IDENTIFIER=%.256s\n", LOG_PRI(level), LOG_FAC(level), + gettid(), isempty(file) ? "" : "CODE_FILE=", isempty(file) ? "" : file, isempty(file) ? "" : "\n",