</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>MaxLevelStore=</varname></term>
+ <term><varname>MaxLevelSyslog=</varname></term>
+ <term><varname>MaxLevelKMsg=</varname></term>
+ <term><varname>MaxLevelConsole=</varname></term>
+
+ <listitem><para>Controls the maximum
+ log level of messages that are stored
+ on disk, forwarded to syslog, kmsg or
+ the console (if that is enabled, see
+ above). As argument, takes one of
+ <literal>emerg</literal>,
+ <literal>alert</literal>,
+ <literal>crit</literal>,
+ <literal>err</literal>,
+ <literal>warning</literal>,
+ <literal>notice</literal>,
+ <literal>info</literal>,
+ <literal>debug</literal> or integer
+ values in the range of 0..7 (corresponding
+ to the same levels). Messages equal or below
+ the log level specified are
+ stored/forwarded, messages above are
+ dropped. Defaults to
+ <literal>debug</literal> for
+ <varname>MaxLevelStore=</varname> and
+ <varname>MaxLevelSyslog=</varname>, to
+ ensure that the all messages are
+ written to disk and forwarded to
+ syslog. Defaults to
+ <literal>notice</literal> for
+ <varname>MaxLevelKMsg=</varname> and
+ <literal>info</literal> for
+ <varname>MaxLevelConsole=</varname>.</para></listitem>
+ </varlistentry>
+
<varlistentry>
<term><varname>TTYPath=</varname></term>
DEFINE_CONFIG_PARSE_ENUM(config_parse_output, exec_output, ExecOutput, "Failed to parse output specifier");
DEFINE_CONFIG_PARSE_ENUM(config_parse_input, exec_input, ExecInput, "Failed to parse input specifier");
-int config_parse_facility(
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
-
- int *o = data, x;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
- assert(data);
-
- if ((x = log_facility_unshifted_from_string(rvalue)) < 0) {
- log_error("[%s:%u] Failed to parse log facility, ignoring: %s", filename, line, rvalue);
- return 0;
- }
-
- *o = (x << 3) | LOG_PRI(*o);
-
- return 0;
-}
-
-int config_parse_level(
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
-
- int *o = data, x;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
- assert(data);
-
- if ((x = log_level_from_string(rvalue)) < 0) {
- log_error("[%s:%u] Failed to parse log level, ignoring: %s", filename, line, rvalue);
- return 0;
- }
-
- *o = (*o & LOG_FACMASK) | x;
- return 0;
-}
-
int config_parse_exec_io_class(
const char *filename,
unsigned line,
int config_parse_socket_bindtodevice(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_output(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_input(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_facility(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_level(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_exec_io_class(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_exec_io_priority(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_exec_cpu_sched_policy(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
Journal.ForwardToConsole, config_parse_bool, 0, offsetof(Server, forward_to_console)
Journal.ImportKernel, config_parse_bool, 0, offsetof(Server, import_proc_kmsg)
Journal.TTYPath, config_parse_path, 0, offsetof(Server, tty_path)
+Journal.MaxLevelStore, config_parse_level, 0, offsetof(Server, max_level_store)
+Journal.MaxLevelSyslog, config_parse_level, 0, offsetof(Server, max_level_syslog)
+Journal.MaxLevelKMsg, config_parse_level, 0, offsetof(Server, max_level_kmsg)
+Journal.MaxLevelConsole, config_parse_level, 0, offsetof(Server, max_level_console)
if (n == 0)
return;
+ if (LOG_PRI(priority) > s->max_level_store)
+ return;
+
if (!ucred)
goto finish;
log_debug("Failed to forward syslog message: %m");
}
-static void forward_syslog_raw(Server *s, const char *buffer, struct ucred *ucred, struct timeval *tv) {
+static void forward_syslog_raw(Server *s, int priority, const char *buffer, struct ucred *ucred, struct timeval *tv) {
struct iovec iovec;
assert(s);
assert(buffer);
+ if (LOG_PRI(priority) > s->max_level_syslog)
+ return;
+
IOVEC_SET_STRING(iovec, buffer);
forward_syslog_iovec(s, &iovec, 1, ucred, tv);
}
assert(priority <= 999);
assert(message);
+ if (LOG_PRI(priority) > s->max_level_syslog)
+ return;
+
/* First: priority field */
snprintf(header_priority, sizeof(header_priority), "<%i>", priority);
char_array_0(header_priority);
assert(priority <= 999);
assert(message);
+ if (LOG_PRI(priority) > s->max_level_kmsg)
+ return;
+
/* Never allow messages with kernel facility to be written to
* kmsg, regardless where the data comes from. */
priority = fixup_priority(priority);
free(ident_buf);
}
-static void forward_console(Server *s, const char *identifier, const char *message, struct ucred *ucred) {
+static void forward_console(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred) {
struct iovec iovec[4];
char header_pid[16];
int n = 0, fd;
assert(s);
assert(message);
+ if (LOG_PRI(priority) > s->max_level_console)
+ return;
+
/* First: identifier and PID */
if (ucred) {
if (!identifier) {
unsigned n = 0;
int priority = LOG_USER | LOG_INFO;
char *identifier = NULL, *pid = NULL;
+ const char *orig;
assert(s);
assert(buf);
+ orig = buf;
+ parse_syslog_priority((char**) &buf, &priority);
+
if (s->forward_to_syslog)
- forward_syslog_raw(s, buf, ucred, tv);
+ forward_syslog_raw(s, priority, orig, ucred, tv);
- parse_syslog_priority((char**) &buf, &priority);
skip_syslog_date((char**) &buf);
read_identifier(&buf, &identifier, &pid);
forward_kmsg(s, priority, identifier, buf, ucred);
if (s->forward_to_console)
- forward_console(s, identifier, buf, ucred);
+ forward_console(s, priority, identifier, buf, ucred);
IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=syslog");
forward_kmsg(s, priority, identifier, message, ucred);
if (s->forward_to_console)
- forward_console(s, identifier, message, ucred);
+ forward_console(s, priority, identifier, message, ucred);
}
dispatch_message(s, iovec, n, m, ucred, tv, label, label_len, priority);
forward_kmsg(s->server, priority, s->identifier, p, &s->ucred);
if (s->forward_to_console || s->server->forward_to_console)
- forward_console(s->server, s->identifier, p, &s->ucred);
+ forward_console(s->server, priority, s->identifier, p, &s->ucred);
IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=stdout");
s->forward_to_syslog = true;
s->import_proc_kmsg = true;
+ s->max_level_store = LOG_DEBUG;
+ s->max_level_syslog = LOG_DEBUG;
+ s->max_level_kmsg = LOG_NOTICE;
+ s->max_level_console = LOG_INFO;
+
memset(&s->system_metrics, 0xFF, sizeof(s->system_metrics));
memset(&s->runtime_metrics, 0xFF, sizeof(s->runtime_metrics));
#ForwardToConsole=no
#ImportKernel=yes
#TTYPath=/dev/console
+#MaxLevelStore=debug
+#MaxLevelSyslog=debug
+#MaxLevelKMsg=notice
+#MaxLevelConsole=info
unsigned n_stdout_streams;
char *tty_path;
+
+ int max_level_store;
+ int max_level_syslog;
+ int max_level_kmsg;
+ int max_level_console;
} Server;
/* gperf lookup function */
*m = (mode_t) l;
return 0;
}
+
+int config_parse_facility(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+
+ int *o = data, x;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ x = log_facility_unshifted_from_string(rvalue);
+ if (x < 0) {
+ log_error("[%s:%u] Failed to parse log facility, ignoring: %s", filename, line, rvalue);
+ return 0;
+ }
+
+ *o = (x << 3) | LOG_PRI(*o);
+
+ return 0;
+}
+
+int config_parse_level(
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+
+ int *o = data, x;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ x = log_level_from_string(rvalue);
+ if (x < 0) {
+ log_error("[%s:%u] Failed to parse log level, ignoring: %s", filename, line, rvalue);
+ return 0;
+ }
+
+ *o = (*o & LOG_FACMASK) | x;
+ return 0;
+}
int config_parse_usec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_nsec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_mode(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_facility(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_level(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#define DEFINE_CONFIG_PARSE_ENUM(function,name,type,msg) \
int function( \