<variablelist class='environment-variables'>
<varlistentry>
<term><varname>$SYSTEMD_LOG_COLOR</varname></term>
- <listitem><para>Controls whether systemd highlights important
- log messages. This can be overridden with
- <option>--log-color</option>.</para></listitem>
+ <listitem><para>Controls whether systemd highlights important log messages. This can be overridden
+ with <option>--log-color=</option>.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>$SYSTEMD_LOG_LEVEL</varname></term>
- <listitem><para>systemd reads the log level from this
- environment variable. This can be overridden with
- <option>--log-level=</option>.</para></listitem>
+ <listitem><para>systemd reads the log level from this environment variable. This can be overridden
+ with <option>--log-level=</option>.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>$SYSTEMD_LOG_LOCATION</varname></term>
- <listitem><para>Controls whether systemd prints the code
- location along with log messages. This can be overridden with
- <option>--log-location</option>.</para></listitem>
+ <listitem><para>Controls whether systemd prints the code location along with log messages. This can
+ be overridden with <option>--log-location=</option>.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>$SYSTEMD_LOG_TARGET</varname></term>
- <listitem><para>systemd reads the log target from this
- environment variable. This can be overridden with
- <option>--log-target=</option>.</para></listitem>
+ <listitem><para>systemd reads the log target from this environment variable. This can be overridden
+ with <option>--log-target=</option>.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>$SYSTEMD_LOG_TIME</varname></term>
- <listitem><para>Controls whether systemd prefixes log
- messages with the current time. This can be overridden with
- <option>--log-time=</option>.</para></listitem>
+ <listitem><para>Controls whether systemd prefixes log messages with the current time. This can be
+ overridden with <option>--log-time=</option>.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><varname>$SYSTEMD_LOG_TID</varname></term>
+ <listitem><para>Controls whether systemd prefixes log messages with the current thread ID
+ (TID).</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>systemd.log_location</varname></term>
<term><varname>systemd.log_target=</varname></term>
<term><varname>systemd.log_time</varname></term>
+ <term><varname>systemd.log_tid</varname></term>
<listitem><para>Controls log output, with the same effect as the
- <varname>$SYSTEMD_LOG_COLOR</varname>,
- <varname>$SYSTEMD_LOG_LEVEL</varname>,
- <varname>$SYSTEMD_LOG_LOCATION</varname>,
- <varname>$SYSTEMD_LOG_TARGET</varname>,
- <varname>$SYSTEMD_LOG_TIME</varname>, environment variables described above.
- <varname>systemd.log_color</varname>, <varname>systemd.log_location</varname>, and
- <varname>systemd.log_time</varname> can be specified without an argument, with the
- same effect as a positive boolean.</para></listitem>
+ <varname>$SYSTEMD_LOG_COLOR</varname>, <varname>$SYSTEMD_LOG_LEVEL</varname>,
+ <varname>$SYSTEMD_LOG_LOCATION</varname>, <varname>$SYSTEMD_LOG_TARGET</varname>,
+ <varname>$SYSTEMD_LOG_TIME</varname>, <varname>$SYSTEMD_LOG_TID</varname> environment variables
+ described above. <varname>systemd.log_color</varname>, <varname>systemd.log_location</varname>,
+ <varname>systemd.log_time</varname> and <varname>systemd.log_tid=</varname> can be specified without
+ an argument, with the same effect as a positive boolean.</para></listitem>
</varlistentry>
<varlistentry>
#include "io-util.h"
#include "log.h"
#include "macro.h"
+#include "missing_syscall.h"
#include "parse-util.h"
#include "proc-cmdline.h"
#include "process-util.h"
static bool show_color = false;
static bool show_location = false;
static bool show_time = false;
+static bool show_tid = false;
static bool upgrade_syslog_to_journal = false;
static bool always_reopen_console = false;
char location[256],
header_time[FORMAT_TIMESTAMP_MAX],
- prefix[1 + DECIMAL_STR_MAX(int) + 2];
- struct iovec iovec[8] = {};
+ prefix[1 + DECIMAL_STR_MAX(int) + 2],
+ tid_string[3 + DECIMAL_STR_MAX(pid_t) + 1];
+ struct iovec iovec[9];
const char *on = NULL, *off = NULL;
size_t n = 0;
}
}
+ if (show_tid) {
+ xsprintf(tid_string, "(" PID_FMT ") ", gettid());
+ iovec[n++] = IOVEC_MAKE_STRING(tid_string);
+ }
+
if (show_color)
get_log_colors(LOG_PRI(level), &on, &off, NULL);
if (log_show_location_from_string(value ?: "1") < 0)
log_warning("Failed to parse log location setting '%s'. Ignoring.", value);
+ } else if (proc_cmdline_key_streq(key, "systemd.log_tid")) {
+
+ if (log_show_tid_from_string(value ?: "1") < 0)
+ log_warning("Failed to parse log tid setting '%s'. Ignoring.", value);
+
} else if (proc_cmdline_key_streq(key, "systemd.log_time")) {
if (log_show_time_from_string(value ?: "1") < 0)
e = getenv("SYSTEMD_LOG_TIME");
if (e && log_show_time_from_string(e) < 0)
log_warning("Failed to parse log time '%s'. Ignoring.", e);
+
+ e = getenv("SYSTEMD_LOG_TID");
+ if (e && log_show_tid_from_string(e) < 0)
+ log_warning("Failed to parse log tid '%s'. Ignoring.", e);
}
LogTarget log_get_target(void) {
return show_time;
}
+void log_show_tid(bool b) {
+ show_tid = b;
+}
+
+bool log_get_show_tid(void) {
+ return show_tid;
+}
+
int log_show_color_from_string(const char *e) {
int t;
return 0;
}
+int log_show_tid_from_string(const char *e) {
+ int t;
+
+ t = parse_boolean(e);
+ if (t < 0)
+ return t;
+
+ log_show_tid(t);
+ return 0;
+}
+
bool log_on_console(void) {
if (IN_SET(log_target, LOG_TARGET_CONSOLE,
LOG_TARGET_CONSOLE_PREFIXED))