mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
log: Add knob to disable kmsg ratelimiting
This allows us to disable kmsg ratelimiting in the integration tests and mkosi for easier debugging.
This commit is contained in:
parent
6b7e774b5d
commit
8750a06b6c
@ -81,6 +81,14 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='log-ratelimit-kmsg'>
|
||||
<term><varname>$SYSTEMD_LOG_RATELIMIT_KMSG</varname></term>
|
||||
|
||||
<listitem><para id='log-ratelimit-kmsg-body'> Whether to ratelimit kmsg or not. Takes a boolean.
|
||||
Defaults to <literal>true</literal>. If disabled, systemd will not ratelimit messages written to kmsg.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='pager'>
|
||||
<term><varname>$SYSTEMD_PAGER</varname></term>
|
||||
|
||||
|
@ -66,6 +66,7 @@
|
||||
<term><varname>systemd.log_level=</varname></term>
|
||||
<term><varname>systemd.log_location=</varname></term>
|
||||
<term><varname>systemd.log_color</varname></term>
|
||||
<term><varname>systemd.log_ratelimit_kmsg</varname></term>
|
||||
<term><varname>systemd.default_standard_output=</varname></term>
|
||||
<term><varname>systemd.default_standard_error=</varname></term>
|
||||
<term><varname>systemd.setenv=</varname></term>
|
||||
|
@ -680,6 +680,11 @@
|
||||
<para>This can be overridden with <option>--log-target=</option>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$SYSTEMD_LOG_RATELIMIT_KMSG</varname></term>
|
||||
<listitem><xi:include href="common-variables.xml" xpointer="log-ratelimit-kmsg" /></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>$XDG_CONFIG_HOME</varname></term>
|
||||
<term><varname>$XDG_CONFIG_DIRS</varname></term>
|
||||
@ -865,13 +870,16 @@
|
||||
<term><varname>systemd.log_target=</varname></term>
|
||||
<term><varname>systemd.log_time</varname></term>
|
||||
<term><varname>systemd.log_tid</varname></term>
|
||||
<term><varname>systemd.log_ratelimit_kmsg</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>, and <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
|
||||
<varname>$SYSTEMD_LOG_TIME</varname>, <varname>$SYSTEMD_LOG_TID</varname> and
|
||||
<varname>$SYSTEMD_LOG_RATELIMIT_KMSG</varname> environment variables described above.
|
||||
<varname>systemd.log_color</varname>, <varname>systemd.log_location</varname>,
|
||||
<varname>systemd.log_time</varname>, <varname>systemd.log_tid</varname> and
|
||||
<varname>systemd.log_ratelimit_kmsg</varname> can be specified without
|
||||
an argument, with the same effect as a positive boolean.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -50,6 +50,7 @@ static void *log_syntax_callback_userdata = NULL;
|
||||
static LogTarget log_target = LOG_TARGET_CONSOLE;
|
||||
static int log_max_level = LOG_INFO;
|
||||
static int log_facility = LOG_DAEMON;
|
||||
static bool ratelimit_kmsg = true;
|
||||
|
||||
static int console_fd = STDERR_FILENO;
|
||||
static int syslog_fd = -EBADF;
|
||||
@ -552,7 +553,7 @@ static int write_to_kmsg(
|
||||
if (kmsg_fd < 0)
|
||||
return 0;
|
||||
|
||||
if (!ratelimit_below(&ratelimit))
|
||||
if (ratelimit_kmsg && !ratelimit_below(&ratelimit))
|
||||
return 0;
|
||||
|
||||
xsprintf(header_priority, "<%i>", level);
|
||||
@ -1178,6 +1179,17 @@ int log_set_max_level_from_string(const char *e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int log_set_ratelimit_kmsg_from_string(const char *e) {
|
||||
int r;
|
||||
|
||||
r = parse_boolean(e);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
ratelimit_kmsg = r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
|
||||
/*
|
||||
@ -1228,6 +1240,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (log_show_time_from_string(value ?: "1") < 0)
|
||||
log_warning("Failed to parse log time setting '%s'. Ignoring.", value);
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "systemd.log_ratelimit_kmsg")) {
|
||||
|
||||
if (log_set_ratelimit_kmsg_from_string(value ?: "1") < 0)
|
||||
log_warning("Failed to parse log ratelimit kmsg boolean '%s'. Ignoring.", value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1268,6 +1284,10 @@ void log_parse_environment_variables(void) {
|
||||
e = getenv("SYSTEMD_LOG_TID");
|
||||
if (e && log_show_tid_from_string(e) < 0)
|
||||
log_warning("Failed to parse log tid '%s'. Ignoring.", e);
|
||||
|
||||
e = getenv("SYSTEMD_LOG_RATELIMIT_KMSG");
|
||||
if (e && log_set_ratelimit_kmsg_from_string(e) < 0)
|
||||
log_warning("Failed to parse log ratelimit kmsg boolean '%s'. Ignoring.", e);
|
||||
}
|
||||
|
||||
void log_parse_environment(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user