mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
core/executor: use log level specified in LogLevelMax=
Follow-up for cc9f4cad8c.
Otherwise, still unexpected lines may be logged by executor.
This commit is contained in:
@@ -3944,6 +3944,8 @@ int exec_invoke(
|
||||
assert(params);
|
||||
assert(exit_status);
|
||||
|
||||
/* This should be mostly redundant, as the log level is also passed as an argument of the executor,
|
||||
* and is already applied earlier. Just for safety. */
|
||||
if (context->log_level_max >= 0)
|
||||
log_set_max_level(context->log_level_max);
|
||||
|
||||
|
||||
@@ -2153,6 +2153,8 @@ static int exec_context_serialize(const ExecContext *c, FILE *f) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* This is also passed to executor as an argument. So, the information should be redundant in general.
|
||||
* But, let's keep this as is for consistency with other elements of ExecContext. See exec_spawn(). */
|
||||
r = serialize_item_format(f, "exec-context-log-level-max", "%d", c->log_level_max);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -3096,6 +3098,7 @@ static int exec_context_deserialize(ExecContext *c, FILE *f) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else if ((val = startswith(l, "exec-context-log-level-max="))) {
|
||||
/* See comment in serialization. */
|
||||
r = safe_atoi(val, &c->log_level_max);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -434,7 +434,10 @@ int exec_spawn(Unit *unit,
|
||||
if (r < 0)
|
||||
return log_unit_error_errno(unit, r, "Failed to set O_CLOEXEC on serialized fds: %m");
|
||||
|
||||
r = log_level_to_string_alloc(log_get_max_level(), &log_level);
|
||||
/* If LogLevelMax= is specified, then let's use the specified log level at the beginning of the
|
||||
* executor process. To achieve that the specified log level is passed as an argument, rather than
|
||||
* the one for the manager process. */
|
||||
r = log_level_to_string_alloc(context->log_level_max >= 0 ? context->log_level_max : log_get_max_level(), &log_level);
|
||||
if (r < 0)
|
||||
return log_unit_error_errno(unit, r, "Failed to convert log level to string: %m");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user