basic/log: add the log_struct terminator to macro
This way all callers do not need to specify it. Exhaustively tested by running test-log under valgrind ;)
This commit is contained in:
committed by
Lennart Poettering
parent
4055a62faf
commit
a1230ff972
+6
-14
@@ -3400,29 +3400,24 @@ static int exec_child(
|
||||
_cleanup_free_ char *line;
|
||||
|
||||
line = exec_command_line(final_argv);
|
||||
if (line) {
|
||||
if (line)
|
||||
log_struct(LOG_DEBUG,
|
||||
"EXECUTABLE=%s", command->path,
|
||||
LOG_UNIT_MESSAGE(unit, "Executing: %s", line),
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit),
|
||||
NULL);
|
||||
}
|
||||
LOG_UNIT_INVOCATION_ID(unit));
|
||||
}
|
||||
|
||||
execve(command->path, final_argv, accum_env);
|
||||
|
||||
if (errno == ENOENT && (command->flags & EXEC_COMMAND_IGNORE_FAILURE)) {
|
||||
|
||||
log_struct_errno(LOG_INFO, errno,
|
||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||
LOG_UNIT_ID(unit),
|
||||
LOG_UNIT_INVOCATION_ID(unit),
|
||||
LOG_UNIT_MESSAGE(unit, "Executable %s missing, skipping: %m",
|
||||
command->path),
|
||||
"EXECUTABLE=%s", command->path,
|
||||
NULL);
|
||||
|
||||
"EXECUTABLE=%s", command->path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3496,8 +3491,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);
|
||||
LOG_UNIT_INVOCATION_ID(unit));
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
@@ -3522,7 +3516,7 @@ int exec_spawn(Unit *unit,
|
||||
unit->manager->user_lookup_fds[1],
|
||||
&exit_status);
|
||||
|
||||
if (r < 0) {
|
||||
if (r < 0)
|
||||
log_struct_errno(LOG_ERR, r,
|
||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||
LOG_UNIT_ID(unit),
|
||||
@@ -3530,9 +3524,7 @@ int exec_spawn(Unit *unit,
|
||||
LOG_UNIT_MESSAGE(unit, "Failed at step %s spawning %s: %m",
|
||||
exit_status_to_string(exit_status, EXIT_STATUS_SYSTEMD),
|
||||
command->path),
|
||||
"EXECUTABLE=%s", command->path,
|
||||
NULL);
|
||||
}
|
||||
"EXECUTABLE=%s", command->path);
|
||||
|
||||
_exit(exit_status);
|
||||
}
|
||||
|
||||
+3
-6
@@ -818,8 +818,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
|
||||
"JOB_TYPE=%s", job_type_to_string(t),
|
||||
"JOB_RESULT=%s", job_result_to_string(result),
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
NULL);
|
||||
LOG_UNIT_INVOCATION_ID(u));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -829,8 +828,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
|
||||
"JOB_RESULT=%s", job_result_to_string(result),
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
mid,
|
||||
NULL);
|
||||
mid);
|
||||
}
|
||||
|
||||
static void job_emit_status_message(Unit *u, JobType t, JobResult result) {
|
||||
@@ -943,8 +941,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive, bool alr
|
||||
LOG_UNIT_MESSAGE(u, "Job %s/%s failed with result '%s'.",
|
||||
u->id,
|
||||
job_type_to_string(t),
|
||||
job_result_to_string(result)),
|
||||
NULL);
|
||||
job_result_to_string(result)));
|
||||
|
||||
unit_start_on_failure(u);
|
||||
}
|
||||
|
||||
+5
-10
@@ -2555,8 +2555,7 @@ static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint
|
||||
|
||||
log_struct(LOG_DEBUG,
|
||||
"MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR,
|
||||
LOG_MESSAGE("Time has been changed"),
|
||||
NULL);
|
||||
LOG_MESSAGE("Time has been changed"));
|
||||
|
||||
/* Restart the watch */
|
||||
m->time_change_event_source = sd_event_source_unref(m->time_change_event_source);
|
||||
@@ -3354,8 +3353,7 @@ static void log_taint_string(Manager *m) {
|
||||
log_struct(LOG_NOTICE,
|
||||
LOG_MESSAGE("System is tainted: %s", taint),
|
||||
"TAINT=%s", taint,
|
||||
"MESSAGE_ID=" SD_MESSAGE_TAINTED_STR,
|
||||
NULL);
|
||||
"MESSAGE_ID=" SD_MESSAGE_TAINTED_STR);
|
||||
}
|
||||
|
||||
static void manager_notify_finished(Manager *m) {
|
||||
@@ -3402,8 +3400,7 @@ static void manager_notify_finished(Manager *m) {
|
||||
format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
|
||||
format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
|
||||
format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
|
||||
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)),
|
||||
NULL);
|
||||
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)));
|
||||
} else {
|
||||
/* The initrd-less case on bare-metal*/
|
||||
|
||||
@@ -3418,8 +3415,7 @@ static void manager_notify_finished(Manager *m) {
|
||||
buf,
|
||||
format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
|
||||
format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
|
||||
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)),
|
||||
NULL);
|
||||
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)));
|
||||
}
|
||||
} else {
|
||||
/* The container and --user case */
|
||||
@@ -3430,8 +3426,7 @@ static void manager_notify_finished(Manager *m) {
|
||||
"MESSAGE_ID=" SD_MESSAGE_USER_STARTUP_FINISHED_STR,
|
||||
"USERSPACE_USEC="USEC_FMT, userspace_usec,
|
||||
LOG_MESSAGE("Startup finished in %s.",
|
||||
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)),
|
||||
NULL);
|
||||
format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC)));
|
||||
}
|
||||
|
||||
bus_manager_send_finished(m, firmware_usec, loader_usec, kernel_usec, initrd_usec, userspace_usec, total_usec);
|
||||
|
||||
+2
-4
@@ -2067,8 +2067,7 @@ static void service_enter_restart(Service *s) {
|
||||
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);
|
||||
"N_RESTARTS=%u", s->n_restarts);
|
||||
|
||||
/* Notify clients about changed restart counter */
|
||||
unit_add_to_dbus_queue(UNIT(s));
|
||||
@@ -3065,8 +3064,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);
|
||||
LOG_UNIT_INVOCATION_ID(u));
|
||||
|
||||
if (s->result == SERVICE_SUCCESS)
|
||||
s->result = f;
|
||||
|
||||
@@ -400,7 +400,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
|
||||
j->unit->id,
|
||||
unit_id == array ? "ordering cycle" : "dependency",
|
||||
*unit_id, *job_type,
|
||||
unit_ids, NULL);
|
||||
unit_ids);
|
||||
|
||||
if (delete) {
|
||||
const char *status;
|
||||
@@ -409,7 +409,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
|
||||
"MESSAGE=%s: Job %s/%s deleted to break ordering cycle starting with %s/%s",
|
||||
j->unit->id, delete->unit->id, job_type_to_string(delete->type),
|
||||
j->unit->id, job_type_to_string(j->type),
|
||||
unit_ids, NULL);
|
||||
unit_ids);
|
||||
|
||||
if (log_get_show_color())
|
||||
status = ANSI_HIGHLIGHT_RED " SKIP " ANSI_NORMAL;
|
||||
@@ -425,7 +425,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
|
||||
log_struct(LOG_ERR,
|
||||
"MESSAGE=%s: Unable to break cycle starting with %s/%s",
|
||||
j->unit->id, j->unit->id, job_type_to_string(j->type),
|
||||
unit_ids, NULL);
|
||||
unit_ids);
|
||||
|
||||
return sd_bus_error_setf(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC,
|
||||
"Transaction order is cyclic. See system logs for details.");
|
||||
|
||||
+3
-6
@@ -1680,8 +1680,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
|
||||
LOG_MESSAGE("%s", buf),
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
mid,
|
||||
NULL);
|
||||
mid);
|
||||
}
|
||||
|
||||
void unit_status_emit_starting_stopping_reloading(Unit *u, JobType t) {
|
||||
@@ -4681,8 +4680,7 @@ void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
|
||||
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);
|
||||
"WHERE=%s", where);
|
||||
}
|
||||
|
||||
int unit_fail_if_noncanonical(Unit *u, const char* where) {
|
||||
@@ -4708,8 +4706,7 @@ int unit_fail_if_noncanonical(Unit *u, const char* where) {
|
||||
LOG_UNIT_ID(u),
|
||||
LOG_UNIT_INVOCATION_ID(u),
|
||||
LOG_UNIT_MESSAGE(u, "Mount path %s is not canonical (contains a symlink).", where),
|
||||
"WHERE=%s", where,
|
||||
NULL);
|
||||
"WHERE=%s", where);
|
||||
|
||||
return -ELOOP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user