Merge pull request #10809 from keszybz/unit-log-result

Add helper function for logging unit results
This commit is contained in:
Lennart Poettering
2018-11-19 11:07:07 +01:00
committed by GitHub
9 changed files with 16 additions and 34 deletions
+2
View File
@@ -6,6 +6,8 @@ Bugfixes:
manager or system manager can be always set. It would be better to reject
them when parsing config.
* Clarify what IPAddress* matches (source, destination, both?)
External:
* Fedora: add an rpmlint check that verifies that all unit files in the RPM are listed in %systemd_post macros.
+1 -5
View File
@@ -315,11 +315,7 @@ static void automount_enter_dead(Automount *a, AutomountResult f) {
if (a->result == AUTOMOUNT_SUCCESS)
a->result = f;
if (a->result == AUTOMOUNT_SUCCESS)
unit_log_success(UNIT(a));
else
unit_log_failure(UNIT(a), automount_result_to_string(a->result));
unit_log_result(UNIT(a), a->result == AUTOMOUNT_SUCCESS, automount_result_to_string(a->result));
automount_set_state(a, a->result != AUTOMOUNT_SUCCESS ? AUTOMOUNT_FAILED : AUTOMOUNT_DEAD);
}
+1 -5
View File
@@ -799,11 +799,7 @@ static void mount_enter_dead(Mount *m, MountResult f) {
if (m->result == MOUNT_SUCCESS)
m->result = f;
if (m->result == MOUNT_SUCCESS)
unit_log_success(UNIT(m));
else
unit_log_failure(UNIT(m), mount_result_to_string(m->result));
unit_log_result(UNIT(m), m->result == MOUNT_SUCCESS, mount_result_to_string(m->result));
mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD);
m->exec_runtime = exec_runtime_unref(m->exec_runtime, true);
+1 -5
View File
@@ -449,11 +449,7 @@ static void path_enter_dead(Path *p, PathResult f) {
if (p->result == PATH_SUCCESS)
p->result = f;
if (p->result == PATH_SUCCESS)
unit_log_success(UNIT(p));
else
unit_log_failure(UNIT(p), path_result_to_string(p->result));
unit_log_result(UNIT(p), p->result == PATH_SUCCESS, path_result_to_string(p->result));
path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD);
}
+1 -5
View File
@@ -240,11 +240,7 @@ static void scope_enter_dead(Scope *s, ScopeResult f) {
if (s->result == SCOPE_SUCCESS)
s->result = f;
if (s->result == SCOPE_SUCCESS)
unit_log_success(UNIT(s));
else
unit_log_failure(UNIT(s), scope_result_to_string(s->result));
unit_log_result(UNIT(s), s->result == SCOPE_SUCCESS, scope_result_to_string(s->result));
scope_set_state(s, s->result != SCOPE_SUCCESS ? SCOPE_FAILED : SCOPE_DEAD);
}
+1 -4
View File
@@ -1699,10 +1699,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
if (s->result == SERVICE_SUCCESS)
s->result = f;
if (s->result == SERVICE_SUCCESS)
unit_log_success(UNIT(s));
else
unit_log_failure(UNIT(s), service_result_to_string(s->result));
unit_log_result(UNIT(s), s->result == SERVICE_SUCCESS, service_result_to_string(s->result));
if (allow_restart && service_shall_restart(s))
s->will_auto_restart = true;
+1 -5
View File
@@ -653,11 +653,7 @@ static void swap_enter_dead(Swap *s, SwapResult f) {
if (s->result == SWAP_SUCCESS)
s->result = f;
if (s->result == SWAP_SUCCESS)
unit_log_success(UNIT(s));
else
unit_log_failure(UNIT(s), swap_result_to_string(s->result));
unit_log_result(UNIT(s), s->result == SWAP_SUCCESS, swap_result_to_string(s->result));
swap_set_state(s, s->result != SWAP_SUCCESS ? SWAP_FAILED : SWAP_DEAD);
s->exec_runtime = exec_runtime_unref(s->exec_runtime, true);
+1 -5
View File
@@ -288,11 +288,7 @@ static void timer_enter_dead(Timer *t, TimerResult f) {
if (t->result == TIMER_SUCCESS)
t->result = f;
if (t->result == TIMER_SUCCESS)
unit_log_success(UNIT(t));
else
unit_log_failure(UNIT(t), timer_result_to_string(t->result));
unit_log_result(UNIT(t), t->result == TIMER_SUCCESS, timer_result_to_string(t->result));
timer_set_state(t, t->result != TIMER_SUCCESS ? TIMER_FAILED : TIMER_DEAD);
}
+7
View File
@@ -808,6 +808,13 @@ int unit_pid_attachable(Unit *unit, pid_t pid, sd_bus_error *error);
void unit_log_success(Unit *u);
void unit_log_failure(Unit *u, const char *result);
static inline void unit_log_result(Unit *u, bool success, const char *result) {
if (success)
unit_log_success(u);
else
unit_log_failure(u, result);
}
void unit_log_process_exit(Unit *u, int level, const char *kind, const char *command, int code, int status);
/* Macros which append UNIT= or USER_UNIT= to the message */