core/unit: introduce unit_set_debug_invocation()

Given that debug_invocation is a Unit thing, make
service_set_debug_invocation() generic. Plus, don't
say "Service failed", as it would be spurious when
Restart=always.
This commit is contained in:
Mike Yuan
2024-09-04 21:37:20 +02:00
parent 40233f70cc
commit 7f2a7ccf7d
3 changed files with 29 additions and 25 deletions
+16 -3
View File
@@ -5839,14 +5839,27 @@ void unit_unlink_state_files(Unit *u) {
}
}
int unit_overwrite_log_level_max(Unit *u, int log_level_max) {
int unit_set_debug_invocation(Unit *u, bool enable) {
int r;
assert(u);
if (!u->exported_log_level_max)
if (u->debug_invocation == enable)
return 0; /* Nothing to do */
u->debug_invocation = enable;
/* Ensure that the new log level is exported for the journal, in place of the previous one */
return unit_export_log_level_max(u, log_level_max, /* overwrite= */ true);
if (u->exported_log_level_max) {
const ExecContext *ec = unit_get_exec_context(u);
if (ec) {
r = unit_export_log_level_max(u, enable ? LOG_PRI(LOG_DEBUG) : ec->log_level_max, /* overwrite= */ true);
if (r < 0)
return r;
}
}
return 1;
}
int unit_prepare_exec(Unit *u) {