mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
core: make sure to log invocation ID of units also when doing structured logging
This commit is contained in:
parent
8d8631d4c9
commit
f1c50becda
@ -3150,6 +3150,7 @@ static int exec_child(
|
||||
"EXECUTABLE=%s", command->path,
|
||||
LOG_UNIT_MESSAGE(unit, "Executing: %s", line),
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit),
|
||||
NULL);
|
||||
log_close();
|
||||
}
|
||||
@ -3223,6 +3224,7 @@ int exec_spawn(Unit *unit,
|
||||
LOG_UNIT_MESSAGE(unit, "About to execute: %s", line),
|
||||
"EXECUTABLE=%s", command->path,
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit),
|
||||
NULL);
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
@ -3254,6 +3256,7 @@ int exec_spawn(Unit *unit,
|
||||
log_struct_errno(LOG_ERR, r,
|
||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit),
|
||||
LOG_UNIT_MESSAGE(unit, "%s: %m",
|
||||
error_message),
|
||||
"EXECUTABLE=%s", command->path,
|
||||
@ -3262,6 +3265,7 @@ int exec_spawn(Unit *unit,
|
||||
log_struct_errno(LOG_INFO, r,
|
||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit),
|
||||
LOG_UNIT_MESSAGE(unit, "Skipped spawning %s: %m",
|
||||
command->path),
|
||||
"EXECUTABLE=%s", command->path,
|
||||
@ -3270,6 +3274,7 @@ int exec_spawn(Unit *unit,
|
||||
log_struct_errno(LOG_ERR, r,
|
||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit),
|
||||
LOG_UNIT_MESSAGE(unit, "Failed at step %s spawning %s: %m",
|
||||
exit_status_to_string(exit_status, EXIT_STATUS_SYSTEMD),
|
||||
command->path),
|
||||
|
@ -808,6 +808,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
|
||||
LOG_MESSAGE("%s", buf),
|
||||
"RESULT=%s", job_result_to_string(result),
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
@ -816,6 +817,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
|
||||
LOG_MESSAGE("%s", buf),
|
||||
"RESULT=%s", job_result_to_string(result),
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
mid,
|
||||
NULL);
|
||||
}
|
||||
|
@ -631,13 +631,13 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
|
||||
m->unit_log_format_string = "UNIT=%s";
|
||||
|
||||
m->invocation_log_field = "INVOCATION_ID=";
|
||||
m->invocation_log_format_string = "INVOCATION_ID=" SD_ID128_FORMAT_STR;
|
||||
m->invocation_log_format_string = "INVOCATION_ID=%s";
|
||||
} else {
|
||||
m->unit_log_field = "USER_UNIT=";
|
||||
m->unit_log_format_string = "USER_UNIT=%s";
|
||||
|
||||
m->invocation_log_field = "USER_INVOCATION_ID=";
|
||||
m->invocation_log_format_string = "USER_INVOCATION_ID=" SD_ID128_FORMAT_STR;
|
||||
m->invocation_log_format_string = "USER_INVOCATION_ID=%s";
|
||||
}
|
||||
|
||||
m->idle_pipe[0] = m->idle_pipe[1] = m->idle_pipe[2] = m->idle_pipe[3] = -1;
|
||||
|
@ -1956,6 +1956,7 @@ static void service_enter_restart(Service *s) {
|
||||
log_struct(LOG_INFO,
|
||||
"MESSAGE_ID=" SD_MESSAGE_UNIT_RESTART_SCHEDULED_STR,
|
||||
LOG_UNIT_ID(UNIT(s)),
|
||||
LOG_UNIT_INVOCATION_ID(UNIT(s)),
|
||||
LOG_UNIT_MESSAGE(UNIT(s), "Scheduled restart job, restart counter is at %u.", s->n_restarts),
|
||||
"N_RESTARTS=%u", s->n_restarts,
|
||||
NULL);
|
||||
@ -2951,6 +2952,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
"EXIT_CODE=%s", sigchld_code_to_string(code),
|
||||
"EXIT_STATUS=%i", status,
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
NULL);
|
||||
|
||||
if (s->result == SERVICE_SUCCESS)
|
||||
|
@ -1544,6 +1544,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
|
||||
log_struct(LOG_INFO,
|
||||
LOG_MESSAGE("%s", buf),
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
mid,
|
||||
NULL);
|
||||
}
|
||||
@ -4242,6 +4243,7 @@ void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
|
||||
log_struct(LOG_NOTICE,
|
||||
"MESSAGE_ID=" SD_MESSAGE_OVERMOUNTING_STR,
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
LOG_UNIT_MESSAGE(u, "Directory %s to mount over is not empty, mounting anyway.", where),
|
||||
"WHERE=%s", where,
|
||||
NULL);
|
||||
@ -4264,6 +4266,7 @@ int unit_fail_if_symlink(Unit *u, const char* where) {
|
||||
log_struct(LOG_ERR,
|
||||
"MESSAGE_ID=" SD_MESSAGE_OVERMOUNTING_STR,
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
LOG_UNIT_MESSAGE(u, "Mount on symlink %s not allowed.", where),
|
||||
"WHERE=%s", where,
|
||||
NULL);
|
||||
|
@ -710,3 +710,4 @@ int unit_fork_helper_process(Unit *u, pid_t *ret);
|
||||
|
||||
#define LOG_UNIT_MESSAGE(unit, fmt, ...) "MESSAGE=%s: " fmt, (unit)->id, ##__VA_ARGS__
|
||||
#define LOG_UNIT_ID(unit) (unit)->manager->unit_log_format_string, (unit)->id
|
||||
#define LOG_UNIT_INVOCATION_ID(unit) (unit)->manager->invocation_log_format_string, (unit)->invocation_id_string
|
||||
|
Loading…
Reference in New Issue
Block a user