core: use log_unit_debug in *_set_state

This commit is contained in:
Mike Yuan
2024-04-06 22:04:17 +08:00
committed by Luca Boccassi
parent 9dd174dc23
commit b7e4e152cf
3 changed files with 14 additions and 16 deletions

View File

@@ -99,7 +99,8 @@ static void scope_set_state(Scope *s, ScopeState state) {
}
if (state != old_state)
log_debug("%s changed %s -> %s", UNIT(s)->id, scope_state_to_string(old_state), scope_state_to_string(state));
log_unit_debug(UNIT(s), "Changed %s -> %s",
scope_state_to_string(old_state), scope_state_to_string(state));
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true);
}

View File

@@ -27,24 +27,22 @@ static void slice_init(Unit *u) {
u->ignore_on_isolate = true;
}
static void slice_set_state(Slice *t, SliceState state) {
static void slice_set_state(Slice *s, SliceState state) {
SliceState old_state;
assert(t);
assert(s);
if (t->state != state)
bus_unit_send_pending_change_signal(UNIT(t), false);
if (s->state != state)
bus_unit_send_pending_change_signal(UNIT(s), false);
old_state = t->state;
t->state = state;
old_state = s->state;
s->state = state;
if (state != old_state)
log_debug("%s changed %s -> %s",
UNIT(t)->id,
slice_state_to_string(old_state),
slice_state_to_string(state));
log_unit_debug(UNIT(s), "Changed %s -> %s",
slice_state_to_string(old_state), slice_state_to_string(state));
unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true);
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true);
}
static int slice_add_parent_slice(Slice *s) {

View File

@@ -17,6 +17,7 @@ static const UnitActiveState state_translation_table[_TARGET_STATE_MAX] = {
static void target_set_state(Target *t, TargetState state) {
TargetState old_state;
assert(t);
if (t->state != state)
@@ -26,10 +27,8 @@ static void target_set_state(Target *t, TargetState state) {
t->state = state;
if (state != old_state)
log_debug("%s changed %s -> %s",
UNIT(t)->id,
target_state_to_string(old_state),
target_state_to_string(state));
log_unit_debug(UNIT(t), "Changed %s -> %s",
target_state_to_string(old_state), target_state_to_string(state));
unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], /* reload_success = */ true);
}