core: log a few more things under UNIT=...
This commit is contained in:
parent
799de03f51
commit
c1b6628d64
|
@ -914,8 +914,8 @@ int unit_load(Unit *u) {
|
||||||
if (u->on_failure_isolate &&
|
if (u->on_failure_isolate &&
|
||||||
set_size(u->dependencies[UNIT_ON_FAILURE]) > 1) {
|
set_size(u->dependencies[UNIT_ON_FAILURE]) > 1) {
|
||||||
|
|
||||||
log_error("More than one OnFailure= dependencies specified for %s but OnFailureIsolate= enabled. Refusing.",
|
log_error_unit(u->id,
|
||||||
u->id);
|
"More than one OnFailure= dependencies specified for %s but OnFailureIsolate= enabled. Refusing.", u->id);
|
||||||
|
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -934,7 +934,8 @@ fail:
|
||||||
unit_add_to_dbus_queue(u);
|
unit_add_to_dbus_queue(u);
|
||||||
unit_add_to_gc_queue(u);
|
unit_add_to_gc_queue(u);
|
||||||
|
|
||||||
log_debug("Failed to load configuration for %s: %s", u->id, strerror(-r));
|
log_debug_unit(u->id, "Failed to load configuration for %s: %s",
|
||||||
|
u->id, strerror(-r));
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -1031,10 +1032,10 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
|
||||||
SD_MESSAGE_UNIT_RELOADING;
|
SD_MESSAGE_UNIT_RELOADING;
|
||||||
|
|
||||||
log_struct_unit(LOG_INFO,
|
log_struct_unit(LOG_INFO,
|
||||||
u->id,
|
u->id,
|
||||||
MESSAGE_ID(mid),
|
MESSAGE_ID(mid),
|
||||||
"MESSAGE=%s", buf,
|
"MESSAGE=%s", buf,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
@ -1067,13 +1068,14 @@ int unit_start(Unit *u) {
|
||||||
* but we don't want to recheck the condition in that case. */
|
* but we don't want to recheck the condition in that case. */
|
||||||
if (state != UNIT_ACTIVATING &&
|
if (state != UNIT_ACTIVATING &&
|
||||||
!unit_condition_test(u)) {
|
!unit_condition_test(u)) {
|
||||||
log_debug("Starting of %s requested but condition failed. Ignoring.", u->id);
|
log_debug_unit(u->id, "Starting of %s requested but condition failed. Ignoring.", u->id);
|
||||||
return -EALREADY;
|
return -EALREADY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forward to the main object, if we aren't it. */
|
/* Forward to the main object, if we aren't it. */
|
||||||
if ((following = unit_following(u))) {
|
if ((following = unit_following(u))) {
|
||||||
log_debug("Redirecting start request from %s to %s.", u->id, following->id);
|
log_debug_unit(u->id, "Redirecting start request from %s to %s.",
|
||||||
|
u->id, following->id);
|
||||||
return unit_start(following);
|
return unit_start(following);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,7 +1126,8 @@ int unit_stop(Unit *u) {
|
||||||
return -EALREADY;
|
return -EALREADY;
|
||||||
|
|
||||||
if ((following = unit_following(u))) {
|
if ((following = unit_following(u))) {
|
||||||
log_debug("Redirecting stop request from %s to %s.", u->id, following->id);
|
log_debug_unit(u->id, "Redirecting stop request from %s to %s.",
|
||||||
|
u->id, following->id);
|
||||||
return unit_stop(following);
|
return unit_stop(following);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,7 +1167,8 @@ int unit_reload(Unit *u) {
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
||||||
if ((following = unit_following(u))) {
|
if ((following = unit_following(u))) {
|
||||||
log_debug("Redirecting reload request from %s to %s.", u->id, following->id);
|
log_debug_unit(u->id, "Redirecting reload request from %s to %s.",
|
||||||
|
u->id, following->id);
|
||||||
return unit_reload(following);
|
return unit_reload(following);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,7 +1221,7 @@ static void unit_check_unneeded(Unit *u) {
|
||||||
if (unit_pending_active(other))
|
if (unit_pending_active(other))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log_info("Service %s is not needed anymore. Stopping.", u->id);
|
log_info_unit(u->id, "Service %s is not needed anymore. Stopping.", u->id);
|
||||||
|
|
||||||
/* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */
|
/* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */
|
||||||
manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
|
manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
|
||||||
|
@ -1309,13 +1313,14 @@ void unit_trigger_on_failure(Unit *u) {
|
||||||
if (set_size(u->dependencies[UNIT_ON_FAILURE]) <= 0)
|
if (set_size(u->dependencies[UNIT_ON_FAILURE]) <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log_info("Triggering OnFailure= dependencies of %s.", u->id);
|
log_info_unit(u->id, "Triggering OnFailure= dependencies of %s.", u->id);
|
||||||
|
|
||||||
SET_FOREACH(other, u->dependencies[UNIT_ON_FAILURE], i) {
|
SET_FOREACH(other, u->dependencies[UNIT_ON_FAILURE], i) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if ((r = manager_add_job(u->manager, JOB_START, other, u->on_failure_isolate ? JOB_ISOLATE : JOB_REPLACE, true, NULL, NULL)) < 0)
|
r = manager_add_job(u->manager, JOB_START, other, u->on_failure_isolate ? JOB_ISOLATE : JOB_REPLACE, true, NULL, NULL);
|
||||||
log_error("Failed to enqueue OnFailure= job: %s", strerror(-r));
|
if (r < 0)
|
||||||
|
log_error_unit(u->id, "Failed to enqueue OnFailure= job: %s", strerror(-r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1454,10 +1459,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
|
||||||
check_unneeded_dependencies(u);
|
check_unneeded_dependencies(u);
|
||||||
|
|
||||||
if (ns != os && ns == UNIT_FAILED) {
|
if (ns != os && ns == UNIT_FAILED) {
|
||||||
log_struct_unit(LOG_NOTICE,
|
log_notice_unit(u->id,
|
||||||
u->id,
|
"MESSAGE=Unit %s entered failed state.", u->id);
|
||||||
"MESSAGE=Unit %s entered failed state.", u->id,
|
|
||||||
NULL);
|
|
||||||
unit_trigger_on_failure(u);
|
unit_trigger_on_failure(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,6 +352,9 @@ static void test_install_printf(void) {
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
log_parse_environment();
|
||||||
|
log_open();
|
||||||
|
|
||||||
test_unit_file_get_set();
|
test_unit_file_get_set();
|
||||||
test_config_parse_exec();
|
test_config_parse_exec();
|
||||||
test_load_env_file_1();
|
test_load_env_file_1();
|
||||||
|
|
Loading…
Reference in a new issue