diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/automount.c | 48 | ||||
-rw-r--r-- | src/core/busname.c | 61 | ||||
-rw-r--r-- | src/core/device.c | 4 | ||||
-rw-r--r-- | src/core/execute.c | 16 | ||||
-rw-r--r-- | src/core/job.c | 24 | ||||
-rw-r--r-- | src/core/kmod-setup.c | 2 | ||||
-rw-r--r-- | src/core/main.c | 2 | ||||
-rw-r--r-- | src/core/manager.c | 14 | ||||
-rw-r--r-- | src/core/mount.c | 59 | ||||
-rw-r--r-- | src/core/path.c | 4 | ||||
-rw-r--r-- | src/core/scope.c | 12 | ||||
-rw-r--r-- | src/core/selinux-access.c | 2 | ||||
-rw-r--r-- | src/core/service.c | 191 | ||||
-rw-r--r-- | src/core/slice.c | 2 | ||||
-rw-r--r-- | src/core/snapshot.c | 12 | ||||
-rw-r--r-- | src/core/socket.c | 156 | ||||
-rw-r--r-- | src/core/swap.c | 42 | ||||
-rw-r--r-- | src/core/timer.c | 30 | ||||
-rw-r--r-- | src/core/transaction.c | 39 | ||||
-rw-r--r-- | src/core/unit.c | 42 | ||||
-rw-r--r-- | src/core/unit.h | 16 |
21 files changed, 392 insertions, 386 deletions
diff --git a/src/core/automount.c b/src/core/automount.c index f72aca2957..f874951f4c 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -151,7 +151,7 @@ static int automount_verify(Automount *a) { return 0; if (path_equal(a->where, "/")) { - log_error_unit(UNIT(a)->id, "Cannot have an automount unit for the root directory. Refusing."); + log_unit_error(UNIT(a)->id, "Cannot have an automount unit for the root directory. Refusing."); return -EINVAL; } @@ -162,7 +162,7 @@ static int automount_verify(Automount *a) { b = unit_has_name(UNIT(a), e); if (!b) { - log_error_unit(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id); + log_unit_error(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id); return -EINVAL; } @@ -226,7 +226,7 @@ static void automount_set_state(Automount *a, AutomountState state) { unmount_autofs(a); if (state != old_state) - log_debug_unit(UNIT(a)->id, + log_unit_debug(UNIT(a)->id, "%s changed %s -> %s", UNIT(a)->id, automount_state_to_string(old_state), @@ -422,9 +422,9 @@ int automount_send_ready(Automount *a, int status) { return ioctl_fd; if (status) - log_debug_unit(UNIT(a)->id, "Sending failure: %s", strerror(-status)); + log_unit_debug(UNIT(a)->id, "Sending failure: %s", strerror(-status)); else - log_debug_unit(UNIT(a)->id, "Sending success."); + log_unit_debug(UNIT(a)->id, "Sending success."); r = 0; @@ -536,7 +536,7 @@ fail: if (mounted) repeat_unmount(a->where); - log_error_unit(UNIT(a)->id, + log_unit_error(UNIT(a)->id, "Failed to initialize automounter: %s", strerror(-r)); automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES); } @@ -551,7 +551,7 @@ static void automount_enter_runnning(Automount *a) { /* We don't take mount requests anymore if we are supposed to * shut down anyway */ if (unit_stop_pending(UNIT(a))) { - log_debug_unit(UNIT(a)->id, + log_unit_debug(UNIT(a)->id, "Suppressing automount request on %s since unit stop is scheduled.", UNIT(a)->id); automount_send_ready(a, -EHOSTDOWN); return; @@ -561,19 +561,19 @@ static void automount_enter_runnning(Automount *a) { /* Before we do anything, let's see if somebody is playing games with us? */ if (lstat(a->where, &st) < 0) { - log_warning_unit(UNIT(a)->id, + log_unit_warning(UNIT(a)->id, "%s failed to stat automount point: %m", UNIT(a)->id); goto fail; } if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id) - log_info_unit(UNIT(a)->id, + log_unit_info(UNIT(a)->id, "%s's automount point already active?", UNIT(a)->id); else { r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_TRIGGER(UNIT(a)), JOB_REPLACE, true, &error, NULL); if (r < 0) { - log_warning_unit(UNIT(a)->id, + log_unit_warning(UNIT(a)->id, "%s failed to queue mount startup job: %s", UNIT(a)->id, bus_error_message(&error, r)); goto fail; @@ -594,7 +594,7 @@ static int automount_start(Unit *u) { assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED); if (path_is_mount_point(a->where, false)) { - log_error_unit(u->id, + log_unit_error(u->id, "Path %s is already a mount point, refusing start for %s", a->where, u->id); return -EEXIST; @@ -659,7 +659,7 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu state = automount_state_from_string(value); if (state < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else a->deserialized_state = state; } else if (streq(key, "result")) { @@ -667,7 +667,7 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu f = automount_result_from_string(value); if (f < 0) - log_debug_unit(u->id, "Failed to parse result value %s", value); + log_unit_debug(u->id, "Failed to parse result value %s", value); else if (f != AUTOMOUNT_SUCCESS) a->result = f; @@ -675,14 +675,14 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu unsigned d; if (safe_atou(value, &d) < 0) - log_debug_unit(u->id, "Failed to parse dev-id value %s", value); + log_unit_debug(u->id, "Failed to parse dev-id value %s", value); else a->dev_id = (unsigned) d; } else if (streq(key, "token")) { unsigned token; if (safe_atou(value, &token) < 0) - log_debug_unit(u->id, "Failed to parse token value %s", value); + log_unit_debug(u->id, "Failed to parse token value %s", value); else { if (!a->tokens) if (!(a->tokens = set_new(NULL))) @@ -696,13 +696,13 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu int fd; if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse pipe-fd value %s", value); + log_unit_debug(u->id, "Failed to parse pipe-fd value %s", value); else { safe_close(a->pipe_fd); a->pipe_fd = fdset_remove(fds, fd); } } else - log_debug_unit(u->id, "Unknown serialization key '%s'", key); + log_unit_debug(u->id, "Unknown serialization key '%s'", key); return 0; } @@ -738,13 +738,13 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo assert(fd == a->pipe_fd); if (events != EPOLLIN) { - log_error_unit(UNIT(a)->id, "Got invalid poll event on pipe."); + log_unit_error(UNIT(a)->id, "Got invalid poll event on pipe."); goto fail; } l = loop_read(a->pipe_fd, &packet, sizeof(packet), true); if (l != sizeof(packet)) { - log_error_unit(UNIT(a)->id, "Invalid read from pipe: %s", l < 0 ? strerror(-l) : "short read"); + log_unit_error(UNIT(a)->id, "Invalid read from pipe: %s", l < 0 ? strerror(-l) : "short read"); goto fail; } @@ -756,21 +756,21 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo _cleanup_free_ char *p = NULL; get_process_comm(packet.v5_packet.pid, &p); - log_info_unit(UNIT(a)->id, + log_unit_info(UNIT(a)->id, "Got automount request for %s, triggered by "PID_FMT" (%s)", a->where, packet.v5_packet.pid, strna(p)); } else - log_debug_unit(UNIT(a)->id, "Got direct mount request on %s", a->where); + log_unit_debug(UNIT(a)->id, "Got direct mount request on %s", a->where); r = set_ensure_allocated(&a->tokens, NULL); if (r < 0) { - log_error_unit(UNIT(a)->id, "Failed to allocate token set."); + log_unit_error(UNIT(a)->id, "Failed to allocate token set."); goto fail; } r = set_put(a->tokens, UINT_TO_PTR(packet.v5_packet.wait_queue_token)); if (r < 0) { - log_error_unit(UNIT(a)->id, "Failed to remember token: %s", strerror(-r)); + log_unit_error(UNIT(a)->id, "Failed to remember token: %s", strerror(-r)); goto fail; } @@ -778,7 +778,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo break; default: - log_error_unit(UNIT(a)->id, "Received unknown automount request %i", packet.hdr.type); + log_unit_error(UNIT(a)->id, "Received unknown automount request %i", packet.hdr.type); break; } diff --git a/src/core/busname.c b/src/core/busname.c index 8926c6bd94..2ad6c6e137 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -200,13 +200,13 @@ static int busname_verify(BusName *n) { return 0; if (!service_name_is_valid(n->name)) { - log_error_unit(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id); + log_unit_error(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id); return -EINVAL; } e = strappenda(n->name, ".busname"); if (!unit_has_name(UNIT(n), e)) { - log_error_unit(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id); + log_unit_error(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id); return -EINVAL; } @@ -268,7 +268,7 @@ static void busname_unwatch_fd(BusName *n) { r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_OFF); if (r < 0) - log_debug_unit(UNIT(n)->id, "Failed to disable event source."); + log_unit_debug(UNIT(n)->id, "Failed to disable event source."); } static int busname_watch_fd(BusName *n) { @@ -284,7 +284,7 @@ static int busname_watch_fd(BusName *n) { else r = sd_event_add_io(UNIT(n)->manager->event, &n->starter_event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n); if (r < 0) { - log_warning_unit(UNIT(n)->id, "Failed to watch starter fd: %s", strerror(-r)); + log_unit_warning(UNIT(n)->id, "Failed to watch starter fd: %s", strerror(-r)); busname_unwatch_fd(n); return r; } @@ -304,7 +304,7 @@ static int busname_open_fd(BusName *n) { mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user"; n->starter_fd = bus_kernel_open_bus_fd(mode, &path); if (n->starter_fd < 0) { - log_warning_unit(UNIT(n)->id, "Failed to open %s: %s", path ?: "kdbus", strerror(-n->starter_fd)); + log_unit_warning(UNIT(n)->id, "Failed to open %s: %s", path ?: "kdbus", strerror(-n->starter_fd)); return n->starter_fd; } @@ -330,7 +330,7 @@ static void busname_set_state(BusName *n, BusNameState state) { busname_close_fd(n); if (state != old_state) - log_debug_unit(UNIT(n)->id, "%s changed %s -> %s", + log_unit_debug(UNIT(n)->id, "%s changed %s -> %s", UNIT(n)->id, busname_state_to_string(old_state), busname_state_to_string(state)); unit_notify(UNIT(n), state_translation_table[old_state], state_translation_table[state], true); @@ -453,14 +453,14 @@ static void busname_enter_signal(BusName *n, BusNameState state, BusNameResult f n->control_pid, false); if (r < 0) { - log_warning_unit(UNIT(n)->id, "%s failed to kill control process: %s", UNIT(n)->id, strerror(-r)); + log_unit_warning(UNIT(n)->id, "%s failed to kill control process: %s", UNIT(n)->id, strerror(-r)); goto fail; } if (r > 0) { r = busname_arm_timer(n); if (r < 0) { - log_warning_unit(UNIT(n)->id, "%s failed to arm timer: %s", UNIT(n)->id, strerror(-r)); + log_unit_warning(UNIT(n)->id, "%s failed to arm timer: %s", UNIT(n)->id, strerror(-r)); goto fail; } @@ -484,7 +484,7 @@ static void busname_enter_listening(BusName *n) { if (n->activating) { r = busname_watch_fd(n); if (r < 0) { - log_warning_unit(UNIT(n)->id, "%s failed to watch names: %s", UNIT(n)->id, strerror(-r)); + log_unit_warning(UNIT(n)->id, "%s failed to watch names: %s", UNIT(n)->id, strerror(-r)); goto fail; } @@ -515,7 +515,7 @@ static void busname_enter_making(BusName *n) { r = busname_make_starter(n, &n->control_pid); if (r < 0) { - log_warning_unit(UNIT(n)->id, "%s failed to fork 'making' task: %s", UNIT(n)->id, strerror(-r)); + log_unit_warning(UNIT(n)->id, "%s failed to fork 'making' task: %s", UNIT(n)->id, strerror(-r)); goto fail; } @@ -526,7 +526,7 @@ static void busname_enter_making(BusName *n) { r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, NULL, n->policy_world); if (r < 0) { - log_warning_unit(UNIT(n)->id, "%s failed to make starter: %s", UNIT(n)->id, strerror(-r)); + log_unit_warning(UNIT(n)->id, "%s failed to make starter: %s", UNIT(n)->id, strerror(-r)); goto fail; } @@ -555,7 +555,7 @@ static void busname_enter_running(BusName *n) { * shut down anyway */ if (unit_stop_pending(UNIT(n))) { - log_debug_unit(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id); + log_unit_debug(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id); /* Flush all queued activation reqeuest by closing and reopening the connection */ bus_kernel_drop_one(n->starter_fd); @@ -582,7 +582,7 @@ static void busname_enter_running(BusName *n) { return; fail: - log_warning_unit(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r)); + log_unit_warning(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r)); busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES); } @@ -606,7 +606,7 @@ static int busname_start(Unit *u) { service = SERVICE(UNIT_DEREF(n->service)); if (UNIT(service)->load_state != UNIT_LOADED) { - log_error_unit(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id); + log_unit_error(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id); return -ENOENT; } } @@ -680,7 +680,7 @@ static int busname_deserialize_item(Unit *u, const char *key, const char *value, state = busname_state_from_string(value); if (state < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else n->deserialized_state = state; @@ -689,7 +689,7 @@ static int busname_deserialize_item(Unit *u, const char *key, const char *value, f = busname_result_from_string(value); if (f < 0) - log_debug_unit(u->id, "Failed to parse result value %s", value); + log_unit_debug(u->id, "Failed to parse result value %s", value); else if (f != BUSNAME_SUCCESS) n->result = f; @@ -697,20 +697,20 @@ static int busname_deserialize_item(Unit *u, const char *key, const char *value, pid_t pid; if (parse_pid(value, &pid) < 0) - log_debug_unit(u->id, "Failed to parse control-pid value %s", value); + log_unit_debug(u->id, "Failed to parse control-pid value %s", value); else n->control_pid = pid; } else if (streq(key, "starter-fd")) { int fd; if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse starter fd value %s", value); + log_unit_debug(u->id, "Failed to parse starter fd value %s", value); else { safe_close(n->starter_fd); n->starter_fd = fdset_remove(fds, fd); } } else - log_debug_unit(u->id, "Unknown serialization key '%s'", key); + log_unit_debug(u->id, "Unknown serialization key '%s'", key); return 0; } @@ -757,7 +757,7 @@ static int busname_peek_message(BusName *n) { if (errno == EINTR || errno == EAGAIN) return 0; - log_error_unit(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id); + log_unit_error(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id); return -errno; } @@ -774,7 +774,7 @@ static int busname_peek_message(BusName *n) { p = mmap(NULL, sz, PROT_READ, MAP_SHARED, n->starter_fd, start); if (p == MAP_FAILED) { - log_error_unit(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id); + log_unit_error(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id); r = -errno; goto finish; } @@ -794,7 +794,7 @@ static int busname_peek_message(BusName *n) { } if (pid > 0) - log_debug_unit(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm)); + log_unit_debug(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm)); r = 0; @@ -804,7 +804,7 @@ finish: cmd_free.offset = cmd_recv.offset; if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0) - log_warning_unit(UNIT(n)->id, "Failed to free peeked message, ignoring: %m"); + log_unit_warning(UNIT(n)->id, "Failed to free peeked message, ignoring: %m"); return r; } @@ -818,10 +818,10 @@ static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents if (n->state != BUSNAME_LISTENING) return 0; - log_debug_unit(UNIT(n)->id, "Activation request on %s", UNIT(n)->id); + log_unit_debug(UNIT(n)->id, "Activation request on %s", UNIT(n)->id); if (revents != EPOLLIN) { - log_error_unit(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.", + log_unit_error(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.", UNIT(n)->id, revents); goto fail; } @@ -858,8 +858,9 @@ static void busname_sigchld_event(Unit *u, pid_t pid, int code, int status) { else assert_not_reached("Unknown sigchld code"); - log_full_unit(f == BUSNAME_SUCCESS ? LOG_DEBUG : LOG_NOTICE, - u->id, "%s control process exited, code=%s status=%i", + log_unit_full(u->id, + f == BUSNAME_SUCCESS ? LOG_DEBUG : LOG_NOTICE, + "%s control process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status); if (f != BUSNAME_SUCCESS) @@ -896,17 +897,17 @@ static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *us switch (n->state) { case BUSNAME_MAKING: - log_warning_unit(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id); + log_unit_warning(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id); busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_TIMEOUT); break; case BUSNAME_SIGTERM: - log_warning_unit(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id); + log_unit_warning(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id); busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_FAILURE_TIMEOUT); break; case BUSNAME_SIGKILL: - log_warning_unit(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id); + log_unit_warning(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id); busname_enter_dead(n, BUSNAME_FAILURE_TIMEOUT); break; diff --git a/src/core/device.c b/src/core/device.c index 11c4261081..068578dc82 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -98,7 +98,7 @@ static void device_set_state(Device *d, DeviceState state) { d->state = state; if (state != old_state) - log_debug_unit(UNIT(d)->id, + log_unit_debug(UNIT(d)->id, "%s changed %s -> %s", UNIT(d)->id, device_state_to_string(old_state), device_state_to_string(state)); @@ -249,7 +249,7 @@ static int device_add_udev_wants(Unit *u, struct udev_device *dev) { return r; } if (!isempty(state)) - log_warning_unit(u->id, "Property %s on %s has trailing garbage, ignoring.", + log_unit_warning(u->id, "Property %s on %s has trailing garbage, ignoring.", property, strna(udev_device_get_syspath(dev))); return 0; diff --git a/src/core/execute.c b/src/core/execute.c index e6c19993ae..dd182f5564 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -426,7 +426,7 @@ static int setup_output(const ExecContext *context, int fileno, int socket_fd, c case EXEC_OUTPUT_JOURNAL_AND_CONSOLE: r = connect_logger_as(context, o, ident, unit_id, fileno); if (r < 0) { - log_struct_unit(LOG_CRIT, unit_id, + log_unit_struct(LOG_CRIT, unit_id, "MESSAGE=Failed to connect std%s of %s to the journal socket: %s", fileno == STDOUT_FILENO ? "out" : "err", unit_id, strerror(-r), @@ -1549,7 +1549,7 @@ static int exec_child(ExecCommand *command, context->mount_flags); if (err == -EPERM) - log_warning_unit(params->unit_id, "Failed to set up file system namespace due to lack of privileges. Execution sandbox will not be in effect: %s", strerror(-err)); + log_unit_warning(params->unit_id, "Failed to set up file system namespace due to lack of privileges. Execution sandbox will not be in effect: %s", strerror(-err)); else if (err < 0) { *error = EXIT_NAMESPACE; return err; @@ -1751,7 +1751,7 @@ static int exec_child(ExecCommand *command, line = exec_command_line(final_argv); if (line) { log_open(); - log_struct_unit(LOG_DEBUG, + log_unit_struct(LOG_DEBUG, params->unit_id, "EXECUTABLE=%s", command->path, "MESSAGE=Executing: %s", line, @@ -1799,7 +1799,7 @@ int exec_spawn(ExecCommand *command, err = exec_context_load_environment(context, params->unit_id, &files_env); if (err < 0) { - log_struct_unit(LOG_ERR, + log_unit_struct(LOG_ERR, params->unit_id, "MESSAGE=Failed to load environment files: %s", strerror(-err), "ERRNO=%d", -err, @@ -1813,7 +1813,7 @@ int exec_spawn(ExecCommand *command, if (!line) return log_oom(); - log_struct_unit(LOG_DEBUG, + log_unit_struct(LOG_DEBUG, params->unit_id, "EXECUTABLE=%s", command->path, "MESSAGE=About to execute: %s", line, @@ -1851,7 +1851,7 @@ int exec_spawn(ExecCommand *command, _exit(r); } - log_struct_unit(LOG_DEBUG, + log_unit_struct(LOG_DEBUG, params->unit_id, "MESSAGE=Forked %s as "PID_FMT, command->path, pid, @@ -2771,7 +2771,7 @@ int exec_runtime_deserialize_item(ExecRuntime **rt, Unit *u, const char *key, co return r; if (safe_atoi(value, &fd) < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse netns socket value %s", value); + log_unit_debug(u->id, "Failed to parse netns socket value %s", value); else { safe_close((*rt)->netns_storage_socket[0]); (*rt)->netns_storage_socket[0] = fdset_remove(fds, fd); @@ -2784,7 +2784,7 @@ int exec_runtime_deserialize_item(ExecRuntime **rt, Unit *u, const char *key, co return r; if (safe_atoi(value, &fd) < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse netns socket value %s", value); + log_unit_debug(u->id, "Failed to parse netns socket value %s", value); else { safe_close((*rt)->netns_storage_socket[1]); (*rt)->netns_storage_socket[1] = fdset_remove(fds, fd); diff --git a/src/core/job.c b/src/core/job.c index 9adc3fda6a..80fdbde5ab 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -168,7 +168,7 @@ Job* job_install(Job *j) { if (uj->state == JOB_WAITING || (job_type_allows_late_merge(j->type) && job_type_is_superset(uj->type, j->type))) { job_merge_into_installed(uj, j); - log_debug_unit(uj->unit->id, + log_unit_debug(uj->unit->id, "Merged into installed job %s/%s as %u", uj->unit->id, job_type_to_string(uj->type), (unsigned) uj->id); return uj; @@ -178,7 +178,7 @@ Job* job_install(Job *j) { /* XXX It should be safer to queue j to run after uj finishes, but it is * not currently possible to have more than one installed job per unit. */ job_merge_into_installed(uj, j); - log_debug_unit(uj->unit->id, + log_unit_debug(uj->unit->id, "Merged into running job, re-running: %s/%s as %u", uj->unit->id, job_type_to_string(uj->type), (unsigned) uj->id); uj->state = JOB_WAITING; @@ -192,7 +192,7 @@ Job* job_install(Job *j) { *pj = j; j->installed = true; j->manager->n_installed_jobs ++; - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "Installed new job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id); return j; @@ -211,14 +211,14 @@ int job_install_deserialized(Job *j) { pj = (j->type == JOB_NOP) ? &j->unit->nop_job : &j->unit->job; if (*pj) { - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "Unit %s already has a job installed. Not installing deserialized job.", j->unit->id); return -EEXIST; } *pj = j; j->installed = true; - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "Reinstalled deserialized job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id); return 0; @@ -457,7 +457,7 @@ static bool job_is_runnable(Job *j) { } static void job_change_type(Job *j, JobType newtype) { - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "Converting job %s/%s -> %s/%s", j->unit->id, job_type_to_string(j->type), j->unit->id, job_type_to_string(newtype)); @@ -730,7 +730,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) { sd_id128_t mid; mid = result == JOB_DONE ? SD_MESSAGE_UNIT_STARTED : SD_MESSAGE_UNIT_FAILED; - log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR, + log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR, u->id, MESSAGE_ID(mid), "RESULT=%s", job_result_to_string(result), @@ -738,7 +738,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) { NULL); } else if (t == JOB_STOP) - log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR, + log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR, u->id, MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED), "RESULT=%s", job_result_to_string(result), @@ -746,7 +746,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) { NULL); else if (t == JOB_RELOAD) - log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR, + log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR, u->id, MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED), "RESULT=%s", job_result_to_string(result), @@ -772,7 +772,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) { if (j->state == JOB_RUNNING) j->manager->n_running_jobs--; - log_debug_unit(u->id, "Job %s/%s finished, result=%s", + log_unit_debug(u->id, "Job %s/%s finished, result=%s", u->id, job_type_to_string(t), job_result_to_string(result)); job_print_status_message(u, t, result); @@ -837,7 +837,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) { * this context. And JOB_FAILURE is already handled by the * unit itself. */ if (result == JOB_TIMEOUT || result == JOB_DEPENDENCY) { - log_struct_unit(LOG_NOTICE, + log_unit_struct(LOG_NOTICE, u->id, "JOB_TYPE=%s", job_type_to_string(t), "JOB_RESULT=%s", job_result_to_string(result), @@ -873,7 +873,7 @@ static int job_dispatch_timer(sd_event_source *s, uint64_t monotonic, void *user assert(j); assert(s == j->timer_event_source); - log_warning_unit(j->unit->id, "Job %s/%s timed out.", j->unit->id, job_type_to_string(j->type)); + log_unit_warning(j->unit->id, "Job %s/%s timed out.", j->unit->id, job_type_to_string(j->type)); u = j->unit; job_finish_and_invalidate(j, JOB_TIMEOUT, true); diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c index 50af7932f6..019858f092 100644 --- a/src/core/kmod-setup.c +++ b/src/core/kmod-setup.c @@ -44,7 +44,7 @@ static void systemd_kmod_log( /* library logging is enabled at debug only */ DISABLE_WARNING_FORMAT_NONLITERAL; - log_metav(LOG_DEBUG, 0, file, line, fn, format, args); + log_internalv(LOG_DEBUG, 0, file, line, fn, format, args); REENABLE_WARNING; } diff --git a/src/core/main.c b/src/core/main.c index 486602ec0a..78054afc4d 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -468,7 +468,7 @@ static int config_parse_cpu_affinity2( if (c) { if (sched_setaffinity(0, CPU_ALLOC_SIZE(ncpus), c) < 0) - log_warning_unit(unit, "Failed to set CPU affinity: %m"); + log_unit_warning(unit, "Failed to set CPU affinity: %m"); CPU_FREE(c); } diff --git a/src/core/manager.c b/src/core/manager.c index d5d6486cc7..7af502aba6 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -854,7 +854,7 @@ static unsigned manager_dispatch_gc_queue(Manager *m) { if (u->gc_marker == gc_marker + GC_OFFSET_BAD || u->gc_marker == gc_marker + GC_OFFSET_UNSURE) { - log_debug_unit(u->id, "Collecting %s", u->id); + log_unit_debug(u->id, "Collecting %s", u->id); u->gc_marker = gc_marker + GC_OFFSET_BAD; unit_add_to_cleanup_queue(u); } @@ -1173,7 +1173,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove if (mode == JOB_ISOLATE && !unit->allow_isolate) return sd_bus_error_setf(e, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated."); - log_debug_unit(unit->id, + log_unit_debug(unit->id, "Trying to enqueue job %s/%s/%s", unit->id, job_type_to_string(type), job_mode_to_string(mode)); @@ -1199,7 +1199,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove if (r < 0) goto tr_abort; - log_debug_unit(unit->id, + log_unit_debug(unit->id, "Enqueued job %s/%s as %u", unit->id, job_type_to_string(type), (unsigned) tr->anchor_job->id); @@ -1469,7 +1469,7 @@ static void manager_invoke_notify_message(Manager *m, Unit *u, pid_t pid, char * return; } - log_debug_unit(u->id, "Got notification message for unit %s", u->id); + log_unit_debug(u->id, "Got notification message for unit %s", u->id); if (UNIT_VTABLE(u)->notify_message) UNIT_VTABLE(u)->notify_message(u, pid, tags); @@ -1565,7 +1565,7 @@ static void invoke_sigchld_event(Manager *m, Unit *u, siginfo_t *si) { assert(u); assert(si); - log_debug_unit(u->id, "Child "PID_FMT" belongs to %s", si->si_pid, u->id); + log_unit_debug(u->id, "Child "PID_FMT" belongs to %s", si->si_pid, u->id); unit_unwatch_pid(u, si->si_pid); UNIT_VTABLE(u)->sigchld_event(u, si->si_pid, si->si_code, si->si_status); @@ -1637,11 +1637,11 @@ static int manager_start_target(Manager *m, const char *name, JobMode mode) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; int r; - log_debug_unit(name, "Activating special unit %s", name); + log_unit_debug(name, "Activating special unit %s", name); r = manager_add_job_by_name(m, JOB_START, name, mode, true, &error, NULL); if (r < 0) - log_error_unit(name, "Failed to enqueue %s job: %s", name, bus_error_message(&error, r)); + log_unit_error(name, "Failed to enqueue %s job: %s", name, bus_error_message(&error, r)); return r; } diff --git a/src/core/mount.c b/src/core/mount.c index b571db946d..36375f65bc 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -437,22 +437,22 @@ static int mount_verify(Mount *m) { b = unit_has_name(UNIT(m), e); if (!b) { - log_error_unit(UNIT(m)->id, "%s's Where= setting doesn't match unit name. Refusing.", UNIT(m)->id); + log_unit_error(UNIT(m)->id, "%s's Where= setting doesn't match unit name. Refusing.", UNIT(m)->id); return -EINVAL; } if (mount_point_is_api(m->where) || mount_point_ignore(m->where)) { - log_error_unit(UNIT(m)->id, "Cannot create mount unit for API file system %s. Refusing.", m->where); + log_unit_error(UNIT(m)->id, "Cannot create mount unit for API file system %s. Refusing.", m->where); return -EINVAL; } if (UNIT(m)->fragment_path && !m->parameters_fragment.what) { - log_error_unit(UNIT(m)->id, "%s's What setting is missing. Refusing.", UNIT(m)->id); + log_unit_error(UNIT(m)->id, "%s's What setting is missing. Refusing.", UNIT(m)->id); return -EBADMSG; } if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) { - log_error_unit(UNIT(m)->id, "%s has PAM enabled. Kill mode must be set to control-group'. Refusing.",UNIT(m)->id); + log_unit_error(UNIT(m)->id, "%s has PAM enabled. Kill mode must be set to control-group'. Refusing.",UNIT(m)->id); return -EINVAL; } @@ -597,7 +597,7 @@ static void mount_set_state(Mount *m, MountState state) { } if (state != old_state) - log_debug_unit(UNIT(m)->id, + log_unit_debug(UNIT(m)->id, "%s changed %s -> %s", UNIT(m)->id, mount_state_to_string(old_state), @@ -804,7 +804,7 @@ static void mount_enter_signal(Mount *m, MountState state, MountResult f) { return; fail: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s failed to kill processes: %s", UNIT(m)->id, strerror(-r)); if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL) @@ -823,7 +823,7 @@ void warn_if_dir_nonempty(const char *unit, const char* where) { if (r > 0) return; else if (r == 0) - log_struct_unit(LOG_NOTICE, + log_unit_struct(LOG_NOTICE, unit, "MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.", unit, where, @@ -831,7 +831,7 @@ void warn_if_dir_nonempty(const char *unit, const char* where) { MESSAGE_ID(SD_MESSAGE_OVERMOUNTING), NULL); else - log_warning_unit(unit, + log_unit_warning(unit, "MESSAGE=Failed to check directory %s: %s", where, strerror(-r)); } @@ -840,7 +840,7 @@ static int fail_if_symlink(const char *unit, const char* where) { assert(where); if (is_symlink(where) > 0) { - log_struct_unit(LOG_WARNING, + log_unit_struct(LOG_WARNING, unit, "MESSAGE=%s: Mount on symlink %s not allowed.", unit, where, @@ -879,7 +879,7 @@ static void mount_enter_unmounting(Mount *m) { return; fail: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s failed to run 'umount' task: %s", UNIT(m)->id, strerror(-r)); mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES); @@ -934,7 +934,7 @@ static void mount_enter_mounting(Mount *m) { return; fail: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s failed to run 'mount' task: %s", UNIT(m)->id, strerror(-r)); mount_enter_dead(m, MOUNT_FAILURE_RESOURCES); @@ -982,7 +982,7 @@ static void mount_enter_remounting(Mount *m) { return; fail: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s failed to run 'remount' task: %s", UNIT(m)->id, strerror(-r)); m->reload_result = MOUNT_FAILURE_RESOURCES; @@ -1086,7 +1086,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F MountState state; if ((state = mount_state_from_string(value)) < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else m->deserialized_state = state; } else if (streq(key, "result")) { @@ -1094,7 +1094,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F f = mount_result_from_string(value); if (f < 0) - log_debug_unit(UNIT(m)->id, + log_unit_debug(UNIT(m)->id, "Failed to parse result value %s", value); else if (f != MOUNT_SUCCESS) m->result = f; @@ -1104,7 +1104,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F f = mount_result_from_string(value); if (f < 0) - log_debug_unit(UNIT(m)->id, + log_unit_debug(UNIT(m)->id, "Failed to parse reload result value %s", value); else if (f != MOUNT_SUCCESS) m->reload_result = f; @@ -1113,7 +1113,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F pid_t pid; if (parse_pid(value, &pid) < 0) - log_debug_unit(UNIT(m)->id, + log_unit_debug(UNIT(m)->id, "Failed to parse control-pid value %s", value); else m->control_pid = pid; @@ -1121,14 +1121,14 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F MountExecCommand id; if ((id = mount_exec_command_from_string(value)) < 0) - log_debug_unit(UNIT(m)->id, + log_unit_debug(UNIT(m)->id, "Failed to parse exec-command value %s", value); else { m->control_command_id = id; m->control_command = m->exec_command + id; } } else - log_debug_unit(UNIT(m)->id, + log_unit_debug(UNIT(m)->id, "Unknown serialization key '%s'", key); return 0; @@ -1187,7 +1187,8 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) { m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID; } - log_full_unit(f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE, u->id, + log_unit_full(u->id, + f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE, "%s mount process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status); @@ -1255,31 +1256,31 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user case MOUNT_MOUNTING: case MOUNT_MOUNTING_DONE: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s mounting timed out. Stopping.", UNIT(m)->id); mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT); break; case MOUNT_REMOUNTING: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s remounting timed out. Stopping.", UNIT(m)->id); m->reload_result = MOUNT_FAILURE_TIMEOUT; mount_enter_mounted(m, MOUNT_SUCCESS); break; case MOUNT_UNMOUNTING: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s unmounting timed out. Stopping.", UNIT(m)->id); mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT); break; case MOUNT_MOUNTING_SIGTERM: if (m->kill_context.send_sigkill) { - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s mounting timed out. Killing.", UNIT(m)->id); mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s mounting timed out. Skipping SIGKILL. Ignoring.", UNIT(m)->id); @@ -1292,11 +1293,11 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user case MOUNT_REMOUNTING_SIGTERM: if (m->kill_context.send_sigkill) { - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s remounting timed out. Killing.", UNIT(m)->id); mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s remounting timed out. Skipping SIGKILL. Ignoring.", UNIT(m)->id); @@ -1309,11 +1310,11 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user case MOUNT_UNMOUNTING_SIGTERM: if (m->kill_context.send_sigkill) { - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s unmounting timed out. Killing.", UNIT(m)->id); mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s unmounting timed out. Skipping SIGKILL. Ignoring.", UNIT(m)->id); @@ -1327,7 +1328,7 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user case MOUNT_MOUNTING_SIGKILL: case MOUNT_REMOUNTING_SIGKILL: case MOUNT_UNMOUNTING_SIGKILL: - log_warning_unit(UNIT(m)->id, + log_unit_warning(UNIT(m)->id, "%s mount process still around after SIGKILL. Ignoring.", UNIT(m)->id); diff --git a/src/core/path.c b/src/core/path.c index f54c77f6c3..d399238a41 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -320,7 +320,7 @@ static int path_verify(Path *p) { return 0; if (!p->specs) { - log_error_unit(UNIT(p)->id, + log_unit_error(UNIT(p)->id, "%s lacks path setting. Refusing.", UNIT(p)->id); return -EINVAL; } @@ -724,7 +724,7 @@ static void path_trigger_notify(Unit *u, Unit *other) { if (p->state == PATH_RUNNING && UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) { - log_debug_unit(UNIT(p)->id, + log_unit_debug(UNIT(p)->id, "%s got notified about unit deactivation.", UNIT(p)->id); diff --git a/src/core/scope.c b/src/core/scope.c index 0f7c1f97ce..a2b9265061 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -133,7 +133,7 @@ static int scope_verify(Scope *s) { return 0; if (set_isempty(UNIT(s)->pids) && UNIT(s)->manager->n_reloading <= 0) { - log_error_unit(UNIT(s)->id, "Scope %s has no PIDs. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "Scope %s has no PIDs. Refusing.", UNIT(s)->id); return -EINVAL; } @@ -264,7 +264,7 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) { return; fail: - log_warning_unit(UNIT(s)->id, + log_unit_warning(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r)); scope_enter_dead(s, SCOPE_FAILURE_RESOURCES); @@ -405,7 +405,7 @@ static void scope_notify_cgroup_empty_event(Unit *u) { Scope *s = SCOPE(u); assert(u); - log_debug_unit(u->id, "%s: cgroup is empty", u->id); + log_unit_debug(u->id, "%s: cgroup is empty", u->id); if (IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL)) scope_enter_dead(s, SCOPE_SUCCESS); @@ -437,17 +437,17 @@ static int scope_dispatch_timer(sd_event_source *source, usec_t usec, void *user case SCOPE_STOP_SIGTERM: if (s->kill_context.send_sigkill) { - log_warning_unit(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id); scope_enter_signal(s, SCOPE_STOP_SIGKILL, SCOPE_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL.", UNIT(s)->id); scope_enter_dead(s, SCOPE_FAILURE_TIMEOUT); } break; case SCOPE_STOP_SIGKILL: - log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id); scope_enter_dead(s, SCOPE_FAILURE_TIMEOUT); break; diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c index b3835d59a5..a2cc850188 100644 --- a/src/core/selinux-access.c +++ b/src/core/selinux-access.c @@ -112,7 +112,7 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) { #endif va_start(ap, fmt); - log_metav(LOG_USER | LOG_INFO, 0, __FILE__, __LINE__, __FUNCTION__, fmt, ap); + log_internalv(LOG_USER | LOG_INFO, 0, __FILE__, __LINE__, __FUNCTION__, fmt, ap); va_end(ap); return 0; diff --git a/src/core/service.c b/src/core/service.c index 6a27e8f67d..72e8f71e5f 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -137,7 +137,7 @@ static void service_unwatch_pid_file(Service *s) { if (!s->pid_file_pathspec) return; - log_debug_unit(UNIT(s)->id, "Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path); + log_unit_debug(UNIT(s)->id, "Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path); path_spec_unwatch(s->pid_file_pathspec); path_spec_done(s->pid_file_pathspec); free(s->pid_file_pathspec); @@ -167,7 +167,7 @@ static int service_set_main_pid(Service *s, pid_t pid) { s->main_pid_known = true; if (get_parent_of_pid(pid, &ppid) >= 0 && ppid != getpid()) { - log_warning_unit(UNIT(s)->id, "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.", UNIT(s)->id, pid); + log_unit_warning(UNIT(s)->id, "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.", UNIT(s)->id, pid); s->main_pid_alien = true; } else s->main_pid_alien = false; @@ -209,7 +209,7 @@ static void service_start_watchdog(Service *s) { if (s->watchdog_event_source) { r = sd_event_source_set_time(s->watchdog_event_source, s->watchdog_timestamp.monotonic + s->watchdog_usec); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to reset watchdog timer: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to reset watchdog timer: %s", UNIT(s)->id, strerror(-r)); return; } @@ -222,7 +222,7 @@ static void service_start_watchdog(Service *s) { s->watchdog_timestamp.monotonic + s->watchdog_usec, 0, service_dispatch_watchdog, s); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to add watchdog timer: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to add watchdog timer: %s", UNIT(s)->id, strerror(-r)); return; } @@ -232,7 +232,7 @@ static void service_start_watchdog(Service *s) { } if (r < 0) - log_warning_unit(UNIT(s)->id, "%s failed to install watchdog timer: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to install watchdog timer: %s", UNIT(s)->id, strerror(-r)); } static void service_reset_watchdog(Service *s) { @@ -316,45 +316,45 @@ static int service_verify(Service *s) { return 0; if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP]) { - log_error_unit(UNIT(s)->id, "%s lacks both ExecStart= and ExecStop= setting. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s lacks both ExecStart= and ExecStop= setting. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->type != SERVICE_ONESHOT && !s->exec_command[SERVICE_EXEC_START]) { - log_error_unit(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id); return -EINVAL; } if (!s->remain_after_exit && !s->exec_command[SERVICE_EXEC_START]) { - log_error_unit(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->type != SERVICE_ONESHOT && s->exec_command[SERVICE_EXEC_START]->command_next) { - log_error_unit(UNIT(s)->id, "%s has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->type == SERVICE_ONESHOT && s->restart != SERVICE_RESTART_NO) { - log_error_unit(UNIT(s)->id, "%s has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->type == SERVICE_ONESHOT && !exit_status_set_is_empty(&s->restart_force_status)) { - log_error_unit(UNIT(s)->id, "%s has RestartForceStatus= set, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has RestartForceStatus= set, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->type == SERVICE_DBUS && !s->bus_name) { - log_error_unit(UNIT(s)->id, "%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->bus_name && s->type != SERVICE_DBUS) - log_warning_unit(UNIT(s)->id, "%s has a D-Bus service name specified, but is not of type dbus. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s has a D-Bus service name specified, but is not of type dbus. Ignoring.", UNIT(s)->id); if (s->exec_context.pam_name && !(s->kill_context.kill_mode == KILL_CONTROL_GROUP || s->kill_context.kill_mode == KILL_MIXED)) { - log_error_unit(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing.", UNIT(s)->id); return -EINVAL; } @@ -571,20 +571,20 @@ static int service_load_pid_file(Service *s, bool may_warn) { r = read_one_line_file(s->pid_file, &k); if (r < 0) { if (may_warn) - log_info_unit(UNIT(s)->id, "PID file %s not readable (yet?) after %s.", s->pid_file, service_state_to_string(s->state)); + log_unit_info(UNIT(s)->id, "PID file %s not readable (yet?) after %s.", s->pid_file, service_state_to_string(s->state)); return r; } r = parse_pid(k, &pid); if (r < 0) { if (may_warn) - log_info_unit(UNIT(s)->id, "Failed to read PID from file %s: %s", s->pid_file, strerror(-r)); + log_unit_info(UNIT(s)->id, "Failed to read PID from file %s: %s", s->pid_file, strerror(-r)); return r; } if (!pid_is_alive(pid)) { if (may_warn) - log_info_unit(UNIT(s)->id, "PID "PID_FMT" read from file %s does not exist or is a zombie.", pid, s->pid_file); + log_unit_info(UNIT(s)->id, "PID "PID_FMT" read from file %s does not exist or is a zombie.", pid, s->pid_file); return -ESRCH; } @@ -592,12 +592,12 @@ static int service_load_pid_file(Service *s, bool may_warn) { if (pid == s->main_pid) return 0; - log_debug_unit(UNIT(s)->id, "Main PID changing: "PID_FMT" -> "PID_FMT, s->main_pid, pid); + log_unit_debug(UNIT(s)->id, "Main PID changing: "PID_FMT" -> "PID_FMT, s->main_pid, pid); service_unwatch_main_pid(s); s->main_pid_known = false; } else - log_debug_unit(UNIT(s)->id, "Main PID loaded: "PID_FMT, pid); + log_unit_debug(UNIT(s)->id, "Main PID loaded: "PID_FMT, pid); r = service_set_main_pid(s, pid); if (r < 0) @@ -606,7 +606,7 @@ static int service_load_pid_file(Service *s, bool may_warn) { r = unit_watch_pid(UNIT(s), pid); if (r < 0) { /* FIXME: we need to do something here */ - log_warning_unit(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id); return r; } @@ -633,7 +633,7 @@ static int service_search_main_pid(Service *s) { if (pid <= 0) return -ENOENT; - log_debug_unit(UNIT(s)->id, "Main PID guessed: "PID_FMT, pid); + log_unit_debug(UNIT(s)->id, "Main PID guessed: "PID_FMT, pid); r = service_set_main_pid(s, pid); if (r < 0) return r; @@ -641,7 +641,7 @@ static int service_search_main_pid(Service *s) { r = unit_watch_pid(UNIT(s), pid); if (r < 0) { /* FIXME: we need to do something here */ - log_warning_unit(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id); return r; } @@ -733,7 +733,7 @@ static void service_set_state(Service *s, ServiceState state) { } if (old_state != state) - log_debug_unit(UNIT(s)->id, "%s changed %s -> %s", UNIT(s)->id, service_state_to_string(old_state), service_state_to_string(state)); + log_unit_debug(UNIT(s)->id, "%s changed %s -> %s", UNIT(s)->id, service_state_to_string(old_state), service_state_to_string(state)); unit_notify(UNIT(s), table[old_state], table[state], s->reload_result == SERVICE_SUCCESS); s->reload_result = SERVICE_SUCCESS; @@ -1088,7 +1088,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart) service_set_state(s, s->result != SERVICE_SUCCESS ? SERVICE_FAILED : SERVICE_DEAD); if (s->result != SERVICE_SUCCESS) { - log_warning_unit(UNIT(s)->id, "%s failed.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s failed.", UNIT(s)->id); failure_action(UNIT(s)->manager, s->failure_action, s->reboot_arg); } @@ -1130,7 +1130,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart) return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run install restart timer: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run install restart timer: %s", UNIT(s)->id, strerror(-r)); service_enter_dead(s, SERVICE_FAILURE_RESOURCES, false); } @@ -1167,7 +1167,7 @@ static void service_enter_stop_post(Service *s, ServiceResult f) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r)); service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES); } @@ -1213,7 +1213,7 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r)); if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL || state == SERVICE_STOP_SIGABRT) @@ -1268,7 +1268,7 @@ static void service_enter_stop(Service *s, ServiceResult f) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r)); service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_RESOURCES); } @@ -1330,7 +1330,7 @@ static void service_enter_start_post(Service *s) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r)); service_enter_stop(s, SERVICE_FAILURE_RESOURCES); } @@ -1423,7 +1423,7 @@ static void service_enter_start(Service *s) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r)); service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES); } @@ -1461,7 +1461,7 @@ static void service_enter_start_pre(Service *s) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r)); service_enter_dead(s, SERVICE_FAILURE_RESOURCES, true); } @@ -1473,7 +1473,7 @@ static void service_enter_restart(Service *s) { if (UNIT(s)->job && UNIT(s)->job->type == JOB_STOP) { /* Don't restart things if we are going down anyway */ - log_info_unit(UNIT(s)->id, "Stop job pending for unit, delaying automatic restart."); + log_unit_info(UNIT(s)->id, "Stop job pending for unit, delaying automatic restart."); r = service_arm_timer(s, s->restart_usec); if (r < 0) @@ -1494,11 +1494,11 @@ static void service_enter_restart(Service *s) { * it will be canceled as part of the service_stop() call that * is executed as part of JOB_RESTART. */ - log_debug_unit(UNIT(s)->id, "%s scheduled restart job.", UNIT(s)->id); + log_unit_debug(UNIT(s)->id, "%s scheduled restart job.", UNIT(s)->id); return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to schedule restart job: %s", UNIT(s)->id, bus_error_message(&error, -r)); + log_unit_warning(UNIT(s)->id, "%s failed to schedule restart job: %s", UNIT(s)->id, bus_error_message(&error, -r)); service_enter_dead(s, SERVICE_FAILURE_RESOURCES, false); } @@ -1541,7 +1541,7 @@ static void service_enter_reload(Service *s) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run 'reload' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'reload' task: %s", UNIT(s)->id, strerror(-r)); s->reload_result = SERVICE_FAILURE_RESOURCES; service_enter_running(s, SERVICE_SUCCESS); } @@ -1574,7 +1574,7 @@ static void service_run_next_control(Service *s) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run next control task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run next control task: %s", UNIT(s)->id, strerror(-r)); if (s->state == SERVICE_START_PRE) service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES); @@ -1618,7 +1618,7 @@ static void service_run_next_main(Service *s) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run next main task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run next main task: %s", UNIT(s)->id, strerror(-r)); service_enter_stop(s, SERVICE_FAILURE_RESOURCES); } @@ -1628,7 +1628,7 @@ static int service_start_limit_test(Service *s) { if (ratelimit_test(&s->start_limit)) return 0; - log_warning_unit(UNIT(s)->id, "start request repeated too quickly for %s", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "start request repeated too quickly for %s", UNIT(s)->id); return failure_action(UNIT(s)->manager, s->start_limit_action, s->reboot_arg); } @@ -1836,7 +1836,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, state = service_state_from_string(value); if (state < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else s->deserialized_state = state; } else if (streq(key, "result")) { @@ -1844,7 +1844,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, f = service_result_from_string(value); if (f < 0) - log_debug_unit(u->id, "Failed to parse result value %s", value); + log_unit_debug(u->id, "Failed to parse result value %s", value); else if (f != SERVICE_SUCCESS) s->result = f; @@ -1853,7 +1853,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, f = service_result_from_string(value); if (f < 0) - log_debug_unit(u->id, "Failed to parse reload result value %s", value); + log_unit_debug(u->id, "Failed to parse reload result value %s", value); else if (f != SERVICE_SUCCESS) s->reload_result = f; @@ -1861,14 +1861,14 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, pid_t pid; if (parse_pid(value, &pid) < 0) - log_debug_unit(u->id, "Failed to parse control-pid value %s", value); + log_unit_debug(u->id, "Failed to parse control-pid value %s", value); else s->control_pid = pid; } else if (streq(key, "main-pid")) { pid_t pid; if (parse_pid(value, &pid) < 0) - log_debug_unit(u->id, "Failed to parse main-pid value %s", value); + log_unit_debug(u->id, "Failed to parse main-pid value %s", value); else { service_set_main_pid(s, pid); unit_watch_pid(UNIT(s), pid); @@ -1878,7 +1878,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, b = parse_boolean(value); if (b < 0) - log_debug_unit(u->id, "Failed to parse main-pid-known value %s", value); + log_unit_debug(u->id, "Failed to parse main-pid-known value %s", value); else s->main_pid_known = b; } else if (streq(key, "status-text")) { @@ -1897,7 +1897,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, id = service_exec_command_from_string(value); if (id < 0) - log_debug_unit(u->id, "Failed to parse exec-command value %s", value); + log_unit_debug(u->id, "Failed to parse exec-command value %s", value); else { s->control_command_id = id; s->control_command = s->exec_command[id]; @@ -1906,7 +1906,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, int fd; if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse socket-fd value %s", value); + log_unit_debug(u->id, "Failed to parse socket-fd value %s", value); else { asynchronous_close(s->socket_fd); s->socket_fd = fdset_remove(fds, fd); @@ -1915,7 +1915,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, int fd; if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse endpoint-fd value %s", value); + log_unit_debug(u->id, "Failed to parse endpoint-fd value %s", value); else { safe_close(s->bus_endpoint_fd); s->bus_endpoint_fd = fdset_remove(fds, fd); @@ -1924,21 +1924,21 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, pid_t pid; if (parse_pid(value, &pid) < 0) - log_debug_unit(u->id, "Failed to parse main-exec-status-pid value %s", value); + log_unit_debug(u->id, "Failed to parse main-exec-status-pid value %s", value); else s->main_exec_status.pid = pid; } else if (streq(key, "main-exec-status-code")) { int i; if (safe_atoi(value, &i) < 0) - log_debug_unit(u->id, "Failed to parse main-exec-status-code value %s", value); + log_unit_debug(u->id, "Failed to parse main-exec-status-code value %s", value); else s->main_exec_status.code = i; } else if (streq(key, "main-exec-status-status")) { int i; if (safe_atoi(value, &i) < 0) - log_debug_unit(u->id, "Failed to parse main-exec-status-status value %s", value); + log_unit_debug(u->id, "Failed to parse main-exec-status-status value %s", value); else s->main_exec_status.status = i; } else if (streq(key, "main-exec-status-start")) @@ -1952,11 +1952,11 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, b = parse_boolean(value); if (b < 0) - log_debug_unit(u->id, "Failed to parse forbid-restart value %s", value); + log_unit_debug(u->id, "Failed to parse forbid-restart value %s", value); else s->forbid_restart = b; } else - log_debug_unit(u->id, "Unknown serialization key '%s'", key); + log_unit_debug(u->id, "Unknown serialization key '%s'", key); return 0; } @@ -2019,19 +2019,19 @@ static int service_retry_pid_file(Service *s) { static int service_watch_pid_file(Service *s) { int r; - log_debug_unit(UNIT(s)->id, "Setting watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path); + log_unit_debug(UNIT(s)->id, "Setting watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path); r = path_spec_watch(s->pid_file_pathspec, service_dispatch_io); if (r < 0) goto fail; /* the pidfile might have appeared just before we set the watch */ - log_debug_unit(UNIT(s)->id, "Trying to read %s's PID file %s in case it changed", UNIT(s)->id, s->pid_file_pathspec->path); + log_unit_debug(UNIT(s)->id, "Trying to read %s's PID file %s in case it changed", UNIT(s)->id, s->pid_file_pathspec->path); service_retry_pid_file(s); return 0; fail: - log_error_unit(UNIT(s)->id, "Failed to set a watch for %s's PID file %s: %s", UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r)); + log_unit_error(UNIT(s)->id, "Failed to set a watch for %s's PID file %s: %s", UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r)); service_unwatch_pid_file(s); return r; } @@ -2079,7 +2079,7 @@ static int service_dispatch_io(sd_event_source *source, int fd, uint32_t events, assert(s->pid_file_pathspec); assert(path_spec_owns_inotify_fd(s->pid_file_pathspec, fd)); - log_debug_unit(UNIT(s)->id, "inotify event for %s", UNIT(s)->id); + log_unit_debug(UNIT(s)->id, "inotify event for %s", UNIT(s)->id); if (path_spec_fd_event(p, events) < 0) goto fail; @@ -2103,7 +2103,7 @@ static void service_notify_cgroup_empty_event(Unit *u) { assert(u); - log_debug_unit(u->id, "%s: cgroup is empty", u->id); + log_unit_debug(u->id, "%s: cgroup is empty", u->id); switch (s->state) { @@ -2118,7 +2118,7 @@ static void service_notify_cgroup_empty_event(Unit *u) { /* If we were hoping for the daemon to write its PID file, * we can give up now. */ if (s->pid_file_pathspec) { - log_warning_unit(u->id, "%s never wrote its PID file. Failing.", UNIT(s)->id); + log_unit_warning(u->id, "%s never wrote its PID file. Failing.", UNIT(s)->id); service_unwatch_pid_file(s); if (s->state == SERVICE_START) @@ -2205,7 +2205,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { f = SERVICE_SUCCESS; } - log_struct_unit(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE, + log_unit_struct(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE, u->id, "MESSAGE=%s: main process exited, code=%s, status=%i/%s", u->id, sigchld_code_to_string(code), status, @@ -2226,7 +2226,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { /* There is another command to * * execute, so let's do that. */ - log_debug_unit(u->id, "%s running next main command for state %s", u->id, service_state_to_string(s->state)); + log_unit_debug(u->id, "%s running next main command for state %s", u->id, service_state_to_string(s->state)); service_run_next_main(s); } else { @@ -2293,7 +2293,8 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { f = SERVICE_SUCCESS; } - log_full_unit(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE, u->id, + log_unit_full(u->id, + f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE, "%s: control process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status); @@ -2312,7 +2313,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { /* There is another command to * * execute, so let's do that. */ - log_debug_unit(u->id, "%s running next control command for state %s", u->id, service_state_to_string(s->state)); + log_unit_debug(u->id, "%s running next control command for state %s", u->id, service_state_to_string(s->state)); service_run_next_control(s); } else { @@ -2322,7 +2323,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { s->control_command = NULL; s->control_command_id = _SERVICE_EXEC_COMMAND_INVALID; - log_debug_unit(u->id, "%s got final SIGCHLD for state %s", u->id, service_state_to_string(s->state)); + log_unit_debug(u->id, "%s got final SIGCHLD for state %s", u->id, service_state_to_string(s->state)); switch (s->state) { @@ -2451,38 +2452,38 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us case SERVICE_START_PRE: case SERVICE_START: - log_warning_unit(UNIT(s)->id, "%s %s operation timed out. Terminating.", UNIT(s)->id, s->state == SERVICE_START ? "start" : "start-pre"); + log_unit_warning(UNIT(s)->id, "%s %s operation timed out. Terminating.", UNIT(s)->id, s->state == SERVICE_START ? "start" : "start-pre"); service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT); break; case SERVICE_START_POST: - log_warning_unit(UNIT(s)->id, "%s start-post operation timed out. Stopping.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s start-post operation timed out. Stopping.", UNIT(s)->id); service_enter_stop(s, SERVICE_FAILURE_TIMEOUT); break; case SERVICE_RELOAD: - log_warning_unit(UNIT(s)->id, "%s reload operation timed out. Stopping.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s reload operation timed out. Stopping.", UNIT(s)->id); s->reload_result = SERVICE_FAILURE_TIMEOUT; service_enter_running(s, SERVICE_SUCCESS); break; case SERVICE_STOP: - log_warning_unit(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id); service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_TIMEOUT); break; case SERVICE_STOP_SIGABRT: - log_warning_unit(UNIT(s)->id, + log_unit_warning(UNIT(s)->id, "%s stop-sigabrt timed out. Terminating.", UNIT(s)->id); service_enter_signal(s, SERVICE_STOP_SIGTERM, s->result); break; case SERVICE_STOP_SIGTERM: if (s->kill_context.send_sigkill) { - log_warning_unit(UNIT(s)->id, "%s stop-sigterm timed out. Killing.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stop-sigterm timed out. Killing.", UNIT(s)->id); service_enter_signal(s, SERVICE_STOP_SIGKILL, SERVICE_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(s)->id, "%s stop-sigterm timed out. Skipping SIGKILL.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stop-sigterm timed out. Skipping SIGKILL.", UNIT(s)->id); service_enter_stop_post(s, SERVICE_FAILURE_TIMEOUT); } @@ -2493,33 +2494,33 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us * Must be something we cannot kill, so let's just be * weirded out and continue */ - log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id); service_enter_stop_post(s, SERVICE_FAILURE_TIMEOUT); break; case SERVICE_STOP_POST: - log_warning_unit(UNIT(s)->id, "%s stop-post timed out. Terminating.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stop-post timed out. Terminating.", UNIT(s)->id); service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT); break; case SERVICE_FINAL_SIGTERM: if (s->kill_context.send_sigkill) { - log_warning_unit(UNIT(s)->id, "%s stop-final-sigterm timed out. Killing.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stop-final-sigterm timed out. Killing.", UNIT(s)->id); service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(s)->id, "%s stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.", UNIT(s)->id); service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, false); } break; case SERVICE_FINAL_SIGKILL: - log_warning_unit(UNIT(s)->id, "%s still around after final SIGKILL. Entering failed mode.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s still around after final SIGKILL. Entering failed mode.", UNIT(s)->id); service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, true); break; case SERVICE_AUTO_RESTART: - log_info_unit(UNIT(s)->id, + log_unit_info(UNIT(s)->id, s->restart_usec > 0 ? "%s holdoff time over, scheduling restart." : "%s has no holdoff time, scheduling restart.", @@ -2541,7 +2542,7 @@ static int service_dispatch_watchdog(sd_event_source *source, usec_t usec, void assert(s); assert(source == s->watchdog_event_source); - log_error_unit(UNIT(s)->id, "%s watchdog timeout (limit %s)!", UNIT(s)->id, + log_unit_error(UNIT(s)->id, "%s watchdog timeout (limit %s)!", UNIT(s)->id, format_timespan(t, sizeof(t), s->watchdog_usec, 1)); service_enter_signal(s, SERVICE_STOP_SIGABRT, SERVICE_FAILURE_WATCHDOG); @@ -2558,19 +2559,19 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { assert(u); cc = strv_join(tags, ", "); - log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT" (%s)", + log_unit_debug(u->id, "%s: Got notification message from PID "PID_FMT" (%s)", u->id, pid, isempty(cc) ? "n/a" : cc); if (s->notify_access == NOTIFY_NONE) { - log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception is disabled.", u->id, pid); + log_unit_warning(u->id, "%s: Got notification message from PID "PID_FMT", but reception is disabled.", u->id, pid); return; } if (s->notify_access == NOTIFY_MAIN && pid != s->main_pid) { if (s->main_pid != 0) - log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, u->id, pid, s->main_pid); + log_unit_warning(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, u->id, pid, s->main_pid); else - log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", u->id, pid); + log_unit_debug(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", u->id, pid); return; } @@ -2578,9 +2579,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { e = strv_find_startswith(tags, "MAINPID="); if (e && IN_SET(s->state, SERVICE_START, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD)) { if (parse_pid(e, &pid) < 0) - log_warning_unit(u->id, "Failed to parse MAINPID= field in notification message: %s", e); + log_unit_warning(u->id, "Failed to parse MAINPID= field in notification message: %s", e); else { - log_debug_unit(u->id, "%s: got MAINPID=%s", u->id, e); + log_unit_debug(u->id, "%s: got MAINPID=%s", u->id, e); service_set_main_pid(s, pid); unit_watch_pid(UNIT(s), pid); @@ -2591,7 +2592,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { /* Interpret RELOADING= */ if (strv_find(tags, "RELOADING=1")) { - log_debug_unit(u->id, "%s: got RELOADING=1", u->id); + log_unit_debug(u->id, "%s: got RELOADING=1", u->id); s->notify_state = NOTIFY_RELOADING; if (s->state == SERVICE_RUNNING) @@ -2603,7 +2604,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { /* Interpret READY= */ if (strv_find(tags, "READY=1")) { - log_debug_unit(u->id, "%s: got READY=1", u->id); + log_unit_debug(u->id, "%s: got READY=1", u->id); s->notify_state = NOTIFY_READY; /* Type=notify services inform us about completed @@ -2622,7 +2623,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { /* Interpret STOPPING= */ if (strv_find(tags, "STOPPING=1")) { - log_debug_unit(u->id, "%s: got STOPPING=1", u->id); + log_unit_debug(u->id, "%s: got STOPPING=1", u->id); s->notify_state = NOTIFY_STOPPING; if (s->state == SERVICE_RUNNING) @@ -2638,9 +2639,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { if (!isempty(e)) { if (!utf8_is_valid(e)) - log_warning_unit(u->id, "Status message in notification is not UTF-8 clean."); + log_unit_warning(u->id, "Status message in notification is not UTF-8 clean."); else { - log_debug_unit(u->id, "%s: got STATUS=%s", u->id, e); + log_unit_debug(u->id, "%s: got STATUS=%s", u->id, e); t = strdup(e); if (!t) @@ -2664,9 +2665,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { int status_errno; if (safe_atoi(e, &status_errno) < 0 || status_errno < 0) - log_warning_unit(u->id, "Failed to parse ERRNO= field in notification message: %s", e); + log_unit_warning(u->id, "Failed to parse ERRNO= field in notification message: %s", e); else { - log_debug_unit(u->id, "%s: got ERRNO=%s", u->id, e); + log_unit_debug(u->id, "%s: got ERRNO=%s", u->id, e); if (s->status_errno != status_errno) { s->status_errno = status_errno; @@ -2677,7 +2678,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { /* Interpret WATCHDOG= */ if (strv_find(tags, "WATCHDOG=1")) { - log_debug_unit(u->id, "%s: got WATCHDOG=1", u->id); + log_unit_debug(u->id, "%s: got WATCHDOG=1", u->id); service_reset_watchdog(s); } @@ -2716,11 +2717,11 @@ static void service_bus_name_owner_change( assert(old_owner || new_owner); if (old_owner && new_owner) - log_debug_unit(u->id, "%s's D-Bus name %s changed owner from %s to %s", u->id, name, old_owner, new_owner); + log_unit_debug(u->id, "%s's D-Bus name %s changed owner from %s to %s", u->id, name, old_owner, new_owner); else if (old_owner) - log_debug_unit(u->id, "%s's D-Bus name %s no longer registered by %s", u->id, name, old_owner); + log_unit_debug(u->id, "%s's D-Bus name %s no longer registered by %s", u->id, name, old_owner); else - log_debug_unit(u->id, "%s's D-Bus name %s now registered by %s", u->id, name, new_owner); + log_unit_debug(u->id, "%s's D-Bus name %s now registered by %s", u->id, name, new_owner); s->bus_name_good = !!new_owner; @@ -2749,7 +2750,7 @@ static void service_bus_name_owner_change( if (r >= 0) r = sd_bus_creds_get_pid(creds, &pid); if (r >= 0) { - log_debug_unit(u->id, "%s's D-Bus name %s is now owned by process %u", u->id, name, (unsigned) pid); + log_unit_debug(u->id, "%s's D-Bus name %s is now owned by process %u", u->id, name, (unsigned) pid); service_set_main_pid(s, pid); unit_watch_pid(UNIT(s), pid); diff --git a/src/core/slice.c b/src/core/slice.c index 057feefa0f..a31e629370 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -113,7 +113,7 @@ static int slice_verify(Slice *s) { a = (char*) SPECIAL_ROOT_SLICE; if (!unit_has_name(UNIT_DEREF(UNIT(s)->slice), a)) { - log_error_unit(UNIT(s)->id, + log_unit_error(UNIT(s)->id, "%s located outside its parent slice. Refusing.", UNIT(s)->id); return -EINVAL; } diff --git a/src/core/snapshot.c b/src/core/snapshot.c index c2678cbe6e..900d0d793a 100644 --- a/src/core/snapshot.c +++ b/src/core/snapshot.c @@ -51,7 +51,7 @@ static void snapshot_set_state(Snapshot *s, SnapshotState state) { s->state = state; if (state != old_state) - log_debug_unit(UNIT(s)->id, + log_unit_debug(UNIT(s)->id, "%s changed %s -> %s", UNIT(s)->id, snapshot_state_to_string(old_state), @@ -155,7 +155,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value state = snapshot_state_from_string(value); if (state < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else s->deserialized_state = state; @@ -163,7 +163,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value r = parse_boolean(value); if (r < 0) - log_debug_unit(u->id, "Failed to parse cleanup value %s", value); + log_unit_debug(u->id, "Failed to parse cleanup value %s", value); else s->cleanup = r; @@ -173,7 +173,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value if (r < 0) return r; } else - log_debug_unit(u->id, "Unknown serialization key '%s'", key); + log_unit_debug(u->id, "Unknown serialization key '%s'", key); return 0; } @@ -258,7 +258,7 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e, SNAPSHOT(u)->cleanup = cleanup; *_s = SNAPSHOT(u); - log_info_unit(u->id, "Created snapshot %s.", u->id); + log_unit_info(u->id, "Created snapshot %s.", u->id); return 0; @@ -272,7 +272,7 @@ fail: void snapshot_remove(Snapshot *s) { assert(s); - log_info_unit(UNIT(s)->id, "Removing snapshot %s.", UNIT(s)->id); + log_unit_info(UNIT(s)->id, "Removing snapshot %s.", UNIT(s)->id); unit_add_to_cleanup_queue(UNIT(s)); } diff --git a/src/core/socket.c b/src/core/socket.c index 39652ef560..96fe2d4a41 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -391,33 +391,33 @@ static int socket_verify(Socket *s) { return 0; if (!s->ports) { - log_error_unit(UNIT(s)->id, "%s lacks Listen setting. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s lacks Listen setting. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->accept && have_non_accept_socket(s)) { - log_error_unit(UNIT(s)->id, "%s configured for accepting sockets, but sockets are non-accepting. Refusing.", + log_unit_error(UNIT(s)->id, "%s configured for accepting sockets, but sockets are non-accepting. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->accept && s->max_connections <= 0) { - log_error_unit(UNIT(s)->id, "%s's MaxConnection setting too small. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s's MaxConnection setting too small. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->accept && UNIT_DEREF(s->service)) { - log_error_unit(UNIT(s)->id, "Explicit service configuration for accepting sockets not supported on %s. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "Explicit service configuration for accepting sockets not supported on %s. Refusing.", UNIT(s)->id); return -EINVAL; } if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) { - log_error_unit(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id); return -EINVAL; } if (!strv_isempty(s->symlinks) && !socket_find_symlink_target(s)) { - log_error_unit(UNIT(s)->id, "%s has symlinks set but none or more than one node in the file system. Refusing.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has symlinks set but none or more than one node in the file system. Refusing.", UNIT(s)->id); return -EINVAL; } @@ -815,60 +815,60 @@ static void socket_apply_socket_options(Socket *s, int fd) { if (s->keep_alive) { int b = s->keep_alive; if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &b, sizeof(b)) < 0) - log_warning_unit(UNIT(s)->id, "SO_KEEPALIVE failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_KEEPALIVE failed: %m"); } if (s->keep_alive_time) { int value = s->keep_alive_time / USEC_PER_SEC; if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &value, sizeof(value)) < 0) - log_warning_unit(UNIT(s)->id, "TCP_KEEPIDLE failed: %m"); + log_unit_warning(UNIT(s)->id, "TCP_KEEPIDLE failed: %m"); } if (s->keep_alive_interval) { int value = s->keep_alive_interval / USEC_PER_SEC; if (setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &value, sizeof(value)) < 0) - log_warning_unit(UNIT(s)->id, "TCP_KEEPINTVL failed: %m"); + log_unit_warning(UNIT(s)->id, "TCP_KEEPINTVL failed: %m"); } if (s->keep_alive_cnt) { int value = s->keep_alive_cnt; if (setsockopt(fd, SOL_SOCKET, TCP_KEEPCNT, &value, sizeof(value)) < 0) - log_warning_unit(UNIT(s)->id, "TCP_KEEPCNT failed: %m"); + log_unit_warning(UNIT(s)->id, "TCP_KEEPCNT failed: %m"); } if (s->defer_accept) { int value = s->defer_accept / USEC_PER_SEC; if (setsockopt(fd, SOL_TCP, TCP_DEFER_ACCEPT, &value, sizeof(value)) < 0) - log_warning_unit(UNIT(s)->id, "TCP_DEFER_ACCEPT failed: %m"); + log_unit_warning(UNIT(s)->id, "TCP_DEFER_ACCEPT failed: %m"); } if (s->no_delay) { int b = s->no_delay; if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0) - log_warning_unit(UNIT(s)->id, "TCP_NODELAY failed: %m"); + log_unit_warning(UNIT(s)->id, "TCP_NODELAY failed: %m"); } if (s->broadcast) { int one = 1; if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) < 0) - log_warning_unit(UNIT(s)->id, "SO_BROADCAST failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_BROADCAST failed: %m"); } if (s->pass_cred) { int one = 1; if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0) - log_warning_unit(UNIT(s)->id, "SO_PASSCRED failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_PASSCRED failed: %m"); } if (s->pass_sec) { int one = 1; if (setsockopt(fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one)) < 0) - log_warning_unit(UNIT(s)->id, "SO_PASSSEC failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_PASSSEC failed: %m"); } if (s->priority >= 0) if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &s->priority, sizeof(s->priority)) < 0) - log_warning_unit(UNIT(s)->id, "SO_PRIORITY failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_PRIORITY failed: %m"); if (s->receive_buffer > 0) { int value = (int) s->receive_buffer; @@ -877,23 +877,23 @@ static void socket_apply_socket_options(Socket *s, int fd) { if (setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &value, sizeof(value)) < 0) if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &value, sizeof(value)) < 0) - log_warning_unit(UNIT(s)->id, "SO_RCVBUF failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_RCVBUF failed: %m"); } if (s->send_buffer > 0) { int value = (int) s->send_buffer; if (setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &value, sizeof(value)) < 0) if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, sizeof(value)) < 0) - log_warning_unit(UNIT(s)->id, "SO_SNDBUF failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_SNDBUF failed: %m"); } if (s->mark >= 0) if (setsockopt(fd, SOL_SOCKET, SO_MARK, &s->mark, sizeof(s->mark)) < 0) - log_warning_unit(UNIT(s)->id, "SO_MARK failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_MARK failed: %m"); if (s->ip_tos >= 0) if (setsockopt(fd, IPPROTO_IP, IP_TOS, &s->ip_tos, sizeof(s->ip_tos)) < 0) - log_warning_unit(UNIT(s)->id, "IP_TOS failed: %m"); + log_unit_warning(UNIT(s)->id, "IP_TOS failed: %m"); if (s->ip_ttl >= 0) { int x; @@ -908,30 +908,30 @@ static void socket_apply_socket_options(Socket *s, int fd) { } if (r < 0 && x < 0) - log_warning_unit(UNIT(s)->id, + log_unit_warning(UNIT(s)->id, "IP_TTL/IPV6_UNICAST_HOPS failed: %m"); } if (s->tcp_congestion) if (setsockopt(fd, SOL_TCP, TCP_CONGESTION, s->tcp_congestion, strlen(s->tcp_congestion)+1) < 0) - log_warning_unit(UNIT(s)->id, "TCP_CONGESTION failed: %m"); + log_unit_warning(UNIT(s)->id, "TCP_CONGESTION failed: %m"); if (s->reuse_port) { int b = s->reuse_port; if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &b, sizeof(b)) < 0) - log_warning_unit(UNIT(s)->id, "SO_REUSEPORT failed: %m"); + log_unit_warning(UNIT(s)->id, "SO_REUSEPORT failed: %m"); } if (s->smack_ip_in) { r = mac_smack_apply_ip_in_fd(fd, s->smack_ip_in); if (r < 0) - log_error_unit(UNIT(s)->id, "mac_smack_apply_ip_in_fd: %s", strerror(-r)); + log_unit_error(UNIT(s)->id, "mac_smack_apply_ip_in_fd: %s", strerror(-r)); } if (s->smack_ip_out) { r = mac_smack_apply_ip_out_fd(fd, s->smack_ip_out); if (r < 0) - log_error_unit(UNIT(s)->id, "mac_smack_apply_ip_out_fd: %s", strerror(-r)); + log_unit_error(UNIT(s)->id, "mac_smack_apply_ip_out_fd: %s", strerror(-r)); } } @@ -943,12 +943,12 @@ static void socket_apply_fifo_options(Socket *s, int fd) { if (s->pipe_size > 0) if (fcntl(fd, F_SETPIPE_SZ, s->pipe_size) < 0) - log_warning_unit(UNIT(s)->id, "F_SETPIPE_SZ: %m"); + log_unit_warning(UNIT(s)->id, "F_SETPIPE_SZ: %m"); if (s->smack) { r = mac_smack_apply_fd(fd, s->smack); if (r < 0) - log_error_unit(UNIT(s)->id, "mac_smack_apply_fd: %s", strerror(-r)); + log_unit_error(UNIT(s)->id, "mac_smack_apply_fd: %s", strerror(-r)); } } @@ -1249,7 +1249,7 @@ static void socket_unwatch_fds(Socket *s) { r = sd_event_source_set_enabled(p->event_source, SD_EVENT_OFF); if (r < 0) - log_debug_unit(UNIT(s)->id, "Failed to disable event source."); + log_unit_debug(UNIT(s)->id, "Failed to disable event source."); } } @@ -1269,7 +1269,7 @@ static int socket_watch_fds(Socket *s) { r = sd_event_add_io(UNIT(s)->manager->event, &p->event_source, p->fd, EPOLLIN, socket_dispatch_io, p); if (r < 0) { - log_warning_unit(UNIT(s)->id, "Failed to watch listening fds: %s", strerror(-r)); + log_unit_warning(UNIT(s)->id, "Failed to watch listening fds: %s", strerror(-r)); goto fail; } } @@ -1319,7 +1319,7 @@ static void socket_set_state(Socket *s, SocketState state) { socket_close_fds(s); if (state != old_state) - log_debug_unit(UNIT(s)->id, "%s changed %s -> %s", + log_unit_debug(UNIT(s)->id, "%s changed %s -> %s", UNIT(s)->id, socket_state_to_string(old_state), socket_state_to_string(state)); unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], true); @@ -1562,7 +1562,7 @@ static void socket_enter_stop_post(Socket *s, SocketResult f) { return; fail: - log_warning_unit(UNIT(s)->id, + log_unit_warning(UNIT(s)->id, "%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r)); socket_enter_signal(s, SOCKET_FINAL_SIGTERM, SOCKET_FAILURE_RESOURCES); @@ -1605,7 +1605,7 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r)); if (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_STOP_PRE_SIGKILL) socket_enter_stop_post(s, SOCKET_FAILURE_RESOURCES); @@ -1636,7 +1636,7 @@ static void socket_enter_stop_pre(Socket *s, SocketResult f) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run 'stop-pre' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'stop-pre' task: %s", UNIT(s)->id, strerror(-r)); socket_enter_stop_post(s, SOCKET_FAILURE_RESOURCES); } @@ -1646,7 +1646,7 @@ static void socket_enter_listening(Socket *s) { r = socket_watch_fds(s); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r)); goto fail; } @@ -1668,7 +1668,7 @@ static void socket_enter_start_post(Socket *s) { if (s->control_command) { r = socket_spawn(s, s->control_command, &s->control_pid); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r)); goto fail; } @@ -1689,7 +1689,7 @@ static void socket_enter_start_chown(Socket *s) { r = socket_open_fds(s); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r)); goto fail; } @@ -1701,7 +1701,7 @@ static void socket_enter_start_chown(Socket *s) { r = socket_chown(s, &s->control_pid); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to fork 'start-chown' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to fork 'start-chown' task: %s", UNIT(s)->id, strerror(-r)); goto fail; } @@ -1726,7 +1726,7 @@ static void socket_enter_start_pre(Socket *s) { if (s->control_command) { r = socket_spawn(s, s->control_command, &s->control_pid); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r)); goto fail; } @@ -1750,7 +1750,7 @@ static void socket_enter_running(Socket *s, int cfd) { * shut down anyway */ if (unit_stop_pending(UNIT(s))) { - log_debug_unit(UNIT(s)->id, "Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id); + log_unit_debug(UNIT(s)->id, "Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id); if (cfd >= 0) safe_close(cfd); @@ -1760,14 +1760,14 @@ static void socket_enter_running(Socket *s, int cfd) { r = socket_open_fds(s); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r)); socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES); return; } r = socket_watch_fds(s); if (r < 0) { - log_warning_unit(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r)); socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES); } } @@ -1790,7 +1790,7 @@ static void socket_enter_running(Socket *s, int cfd) { if (!pending) { if (!UNIT_ISSET(s->service)) { - log_error_unit(UNIT(s)->id, "%s: service to activate vanished, refusing activation.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s: service to activate vanished, refusing activation.", UNIT(s)->id); r = -ENOENT; goto fail; } @@ -1806,7 +1806,7 @@ static void socket_enter_running(Socket *s, int cfd) { Service *service; if (s->n_connections >= s->max_connections) { - log_warning_unit(UNIT(s)->id, "%s: Too many incoming connections (%u)", UNIT(s)->id, s->n_connections); + log_unit_warning(UNIT(s)->id, "%s: Too many incoming connections (%u)", UNIT(s)->id, s->n_connections); safe_close(cfd); return; } @@ -1868,7 +1868,7 @@ static void socket_enter_running(Socket *s, int cfd) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to queue service startup job (Maybe the service file is missing or not a %s unit?): %s", + log_unit_warning(UNIT(s)->id, "%s failed to queue service startup job (Maybe the service file is missing or not a %s unit?): %s", UNIT(s)->id, cfd >= 0 ? "template" : "non-template", bus_error_message(&error, r)); @@ -1894,7 +1894,7 @@ static void socket_run_next(Socket *s) { return; fail: - log_warning_unit(UNIT(s)->id, "%s failed to run next task: %s", UNIT(s)->id, strerror(-r)); + log_unit_warning(UNIT(s)->id, "%s failed to run next task: %s", UNIT(s)->id, strerror(-r)); if (s->state == SOCKET_START_POST) socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES); @@ -1934,7 +1934,7 @@ static int socket_start(Unit *u) { service = SERVICE(UNIT_DEREF(s->service)); if (UNIT(service)->load_state != UNIT_LOADED) { - log_error_unit(u->id, "Socket service %s not loaded, refusing.", UNIT(service)->id); + log_unit_error(u->id, "Socket service %s not loaded, refusing.", UNIT(service)->id); return -ENOENT; } @@ -1943,7 +1943,7 @@ static int socket_start(Unit *u) { if (service->state != SERVICE_DEAD && service->state != SERVICE_FAILED && service->state != SERVICE_AUTO_RESTART) { - log_error_unit(u->id, "Socket service %s already active, refusing.", UNIT(service)->id); + log_unit_error(u->id, "Socket service %s already active, refusing.", UNIT(service)->id); return -EBUSY; } } @@ -2053,7 +2053,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, state = socket_state_from_string(value); if (state < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else s->deserialized_state = state; } else if (streq(key, "result")) { @@ -2061,7 +2061,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, f = socket_result_from_string(value); if (f < 0) - log_debug_unit(u->id, "Failed to parse result value %s", value); + log_unit_debug(u->id, "Failed to parse result value %s", value); else if (f != SOCKET_SUCCESS) s->result = f; @@ -2069,14 +2069,14 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, unsigned k; if (safe_atou(value, &k) < 0) - log_debug_unit(u->id, "Failed to parse n-accepted value %s", value); + log_unit_debug(u->id, "Failed to parse n-accepted value %s", value); else s->n_accepted += k; } else if (streq(key, "control-pid")) { pid_t pid; if (parse_pid(value, &pid) < 0) - log_debug_unit(u->id, "Failed to parse control-pid value %s", value); + log_unit_debug(u->id, "Failed to parse control-pid value %s", value); else s->control_pid = pid; } else if (streq(key, "control-command")) { @@ -2084,7 +2084,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, id = socket_exec_command_from_string(value); if (id < 0) - log_debug_unit(u->id, "Failed to parse exec-command value %s", value); + log_unit_debug(u->id, "Failed to parse exec-command value %s", value); else { s->control_command_id = id; s->control_command = s->exec_command[id]; @@ -2094,7 +2094,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, SocketPort *p; if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse fifo value %s", value); + log_unit_debug(u->id, "Failed to parse fifo value %s", value); else { LIST_FOREACH(port, p, s->ports) @@ -2113,7 +2113,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, SocketPort *p; if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse special value %s", value); + log_unit_debug(u->id, "Failed to parse special value %s", value); else { LIST_FOREACH(port, p, s->ports) @@ -2132,7 +2132,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, SocketPort *p; if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse mqueue value %s", value); + log_unit_debug(u->id, "Failed to parse mqueue value %s", value); else { LIST_FOREACH(port, p, s->ports) @@ -2151,7 +2151,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, SocketPort *p; if (sscanf(value, "%i %i %n", &fd, &type, &skip) < 2 || fd < 0 || type < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse socket value %s", value); + log_unit_debug(u->id, "Failed to parse socket value %s", value); else { LIST_FOREACH(port, p, s->ports) @@ -2169,7 +2169,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, SocketPort *p; if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd)) - log_debug_unit(u->id, "Failed to parse socket value %s", value); + log_unit_debug(u->id, "Failed to parse socket value %s", value); else { LIST_FOREACH(port, p, s->ports) @@ -2182,7 +2182,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, } } } else - log_debug_unit(UNIT(s)->id, "Unknown serialization key '%s'", key); + log_unit_debug(UNIT(s)->id, "Unknown serialization key '%s'", key); return 0; } @@ -2286,15 +2286,15 @@ static int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents, if (p->socket->state != SOCKET_LISTENING) return 0; - log_debug_unit(UNIT(p->socket)->id, "Incoming traffic on %s", UNIT(p->socket)->id); + log_unit_debug(UNIT(p->socket)->id, "Incoming traffic on %s", UNIT(p->socket)->id); if (revents != EPOLLIN) { if (revents & EPOLLHUP) - log_error_unit(UNIT(p->socket)->id, "%s: Got POLLHUP on a listening socket. The service probably invoked shutdown() on it, and should better not do that.", + log_unit_error(UNIT(p->socket)->id, "%s: Got POLLHUP on a listening socket. The service probably invoked shutdown() on it, and should better not do that.", UNIT(p->socket)->id); else - log_error_unit(UNIT(p->socket)->id, "%s: Got unexpected poll event (0x%x) on socket.", + log_unit_error(UNIT(p->socket)->id, "%s: Got unexpected poll event (0x%x) on socket.", UNIT(p->socket)->id, revents); goto fail; @@ -2312,7 +2312,7 @@ static int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents, if (errno == EINTR) continue; - log_error_unit(UNIT(p->socket)->id, + log_unit_error(UNIT(p->socket)->id, "Failed to accept socket: %m"); goto fail; } @@ -2361,8 +2361,8 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) { f = SOCKET_SUCCESS; } - log_full_unit(f == SOCKET_SUCCESS ? LOG_DEBUG : LOG_NOTICE, - u->id, + log_unit_full(u->id, + f == SOCKET_SUCCESS ? LOG_DEBUG : LOG_NOTICE, "%s control process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status); @@ -2373,7 +2373,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) { s->control_command->command_next && f == SOCKET_SUCCESS) { - log_debug_unit(u->id, + log_unit_debug(u->id, "%s running next command for state %s", u->id, socket_state_to_string(s->state)); socket_run_next(s); @@ -2384,7 +2384,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) { /* No further commands for this step, so let's figure * out what to do next */ - log_debug_unit(u->id, + log_unit_debug(u->id, "%s got final SIGCHLD for state %s", u->id, socket_state_to_string(s->state)); @@ -2441,53 +2441,53 @@ static int socket_dispatch_timer(sd_event_source *source, usec_t usec, void *use switch (s->state) { case SOCKET_START_PRE: - log_warning_unit(UNIT(s)->id, "%s starting timed out. Terminating.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s starting timed out. Terminating.", UNIT(s)->id); socket_enter_signal(s, SOCKET_FINAL_SIGTERM, SOCKET_FAILURE_TIMEOUT); break; case SOCKET_START_CHOWN: case SOCKET_START_POST: - log_warning_unit(UNIT(s)->id, "%s starting timed out. Stopping.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s starting timed out. Stopping.", UNIT(s)->id); socket_enter_stop_pre(s, SOCKET_FAILURE_TIMEOUT); break; case SOCKET_STOP_PRE: - log_warning_unit(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id); socket_enter_signal(s, SOCKET_STOP_PRE_SIGTERM, SOCKET_FAILURE_TIMEOUT); break; case SOCKET_STOP_PRE_SIGTERM: if (s->kill_context.send_sigkill) { - log_warning_unit(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id); socket_enter_signal(s, SOCKET_STOP_PRE_SIGKILL, SOCKET_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); socket_enter_stop_post(s, SOCKET_FAILURE_TIMEOUT); } break; case SOCKET_STOP_PRE_SIGKILL: - log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id); socket_enter_stop_post(s, SOCKET_FAILURE_TIMEOUT); break; case SOCKET_STOP_POST: - log_warning_unit(UNIT(s)->id, "%s stopping timed out (2). Terminating.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out (2). Terminating.", UNIT(s)->id); socket_enter_signal(s, SOCKET_FINAL_SIGTERM, SOCKET_FAILURE_TIMEOUT); break; case SOCKET_FINAL_SIGTERM: if (s->kill_context.send_sigkill) { - log_warning_unit(UNIT(s)->id, "%s stopping timed out (2). Killing.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out (2). Killing.", UNIT(s)->id); socket_enter_signal(s, SOCKET_FINAL_SIGKILL, SOCKET_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(s)->id, "%s stopping timed out (2). Skipping SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s stopping timed out (2). Skipping SIGKILL. Ignoring.", UNIT(s)->id); socket_enter_dead(s, SOCKET_FAILURE_TIMEOUT); } break; case SOCKET_FINAL_SIGKILL: - log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL (2). Entering failed mode.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL (2). Entering failed mode.", UNIT(s)->id); socket_enter_dead(s, SOCKET_FAILURE_TIMEOUT); break; @@ -2556,7 +2556,7 @@ static void socket_notify_service_dead(Socket *s, bool failed_permanent) { * services. */ if (s->state == SOCKET_RUNNING) { - log_debug_unit(UNIT(s)->id, "%s got notified about service death (failed permanently: %s)", UNIT(s)->id, yes_no(failed_permanent)); + log_unit_debug(UNIT(s)->id, "%s got notified about service death (failed permanently: %s)", UNIT(s)->id, yes_no(failed_permanent)); if (failed_permanent) socket_enter_stop_pre(s, SOCKET_FAILURE_SERVICE_FAILED_PERMANENT); else @@ -2575,7 +2575,7 @@ void socket_connection_unref(Socket *s) { assert(s->n_connections > 0); s->n_connections--; - log_debug_unit(UNIT(s)->id, "%s: One connection closed, %u left.", UNIT(s)->id, s->n_connections); + log_unit_debug(UNIT(s)->id, "%s: One connection closed, %u left.", UNIT(s)->id, s->n_connections); } static void socket_trigger_notify(Unit *u, Unit *other) { diff --git a/src/core/swap.c b/src/core/swap.c index e509a633d0..fd16104ebb 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -233,12 +233,12 @@ static int swap_verify(Swap *s) { b = unit_has_name(UNIT(s), e); if (!b) { - log_error_unit(UNIT(s)->id, "%s: Value of \"What\" and unit name do not match, not loading.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s: Value of \"What\" and unit name do not match, not loading.", UNIT(s)->id); return -EINVAL; } if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) { - log_error_unit(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing to load.", UNIT(s)->id); + log_unit_error(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing to load.", UNIT(s)->id); return -EINVAL; } @@ -410,7 +410,7 @@ static int swap_add_one( return 0; fail: - log_warning_unit(e, "Failed to load swap unit: %s", strerror(-r)); + log_unit_warning(e, "Failed to load swap unit: %s", strerror(-r)); if (delete && u) unit_free(u); @@ -492,7 +492,7 @@ static void swap_set_state(Swap *s, SwapState state) { } if (state != old_state) - log_debug_unit(UNIT(s)->id, + log_unit_debug(UNIT(s)->id, "%s changed %s -> %s", UNIT(s)->id, swap_state_to_string(old_state), @@ -698,7 +698,7 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) { return; fail: - log_warning_unit(UNIT(s)->id, + log_unit_warning(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r)); swap_enter_dead(s, SWAP_FAILURE_RESOURCES); @@ -827,7 +827,7 @@ static void swap_enter_activating(Swap *s) { return; fail: - log_warning_unit(UNIT(s)->id, + log_unit_warning(UNIT(s)->id, "%s failed to run 'swapon' task: %s", UNIT(s)->id, strerror(-r)); swap_enter_dead(s, SWAP_FAILURE_RESOURCES); @@ -859,7 +859,7 @@ static void swap_enter_deactivating(Swap *s) { return; fail: - log_warning_unit(UNIT(s)->id, + log_unit_warning(UNIT(s)->id, "%s failed to run 'swapoff' task: %s", UNIT(s)->id, strerror(-r)); swap_enter_active(s, SWAP_FAILURE_RESOURCES); @@ -946,7 +946,7 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD state = swap_state_from_string(value); if (state < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else s->deserialized_state = state; } else if (streq(key, "result")) { @@ -954,14 +954,14 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD f = swap_result_from_string(value); if (f < 0) - log_debug_unit(u->id, "Failed to parse result value %s", value); + log_unit_debug(u->id, "Failed to parse result value %s", value); else if (f != SWAP_SUCCESS) s->result = f; } else if (streq(key, "control-pid")) { pid_t pid; if (parse_pid(value, &pid) < 0) - log_debug_unit(u->id, "Failed to parse control-pid value %s", value); + log_unit_debug(u->id, "Failed to parse control-pid value %s", value); else s->control_pid = pid; @@ -970,13 +970,13 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD id = swap_exec_command_from_string(value); if (id < 0) - log_debug_unit(u->id, "Failed to parse exec-command value %s", value); + log_unit_debug(u->id, "Failed to parse exec-command value %s", value); else { s->control_command_id = id; s->control_command = s->exec_command + id; } } else - log_debug_unit(u->id, "Unknown serialization key '%s'", key); + log_unit_debug(u->id, "Unknown serialization key '%s'", key); return 0; } @@ -1034,8 +1034,8 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) { s->control_command_id = _SWAP_EXEC_COMMAND_INVALID; } - log_full_unit(f == SWAP_SUCCESS ? LOG_DEBUG : LOG_NOTICE, - u->id, + log_unit_full(u->id, + f == SWAP_SUCCESS ? LOG_DEBUG : LOG_NOTICE, "%s swap process exited, code=%s status=%i", u->id, sigchld_code_to_string(code), status); @@ -1077,38 +1077,38 @@ static int swap_dispatch_timer(sd_event_source *source, usec_t usec, void *userd case SWAP_ACTIVATING: case SWAP_ACTIVATING_DONE: - log_warning_unit(UNIT(s)->id, "%s activation timed out. Stopping.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s activation timed out. Stopping.", UNIT(s)->id); swap_enter_signal(s, SWAP_ACTIVATING_SIGTERM, SWAP_FAILURE_TIMEOUT); break; case SWAP_DEACTIVATING: - log_warning_unit(UNIT(s)->id, "%s deactivation timed out. Stopping.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Stopping.", UNIT(s)->id); swap_enter_signal(s, SWAP_DEACTIVATING_SIGTERM, SWAP_FAILURE_TIMEOUT); break; case SWAP_ACTIVATING_SIGTERM: if (s->kill_context.send_sigkill) { - log_warning_unit(UNIT(s)->id, "%s activation timed out. Killing.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s activation timed out. Killing.", UNIT(s)->id); swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(s)->id, "%s activation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s activation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); swap_enter_dead(s, SWAP_FAILURE_TIMEOUT); } break; case SWAP_DEACTIVATING_SIGTERM: if (s->kill_context.send_sigkill) { - log_warning_unit(UNIT(s)->id, "%s deactivation timed out. Killing.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Killing.", UNIT(s)->id); swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT); } else { - log_warning_unit(UNIT(s)->id, "%s deactivation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id); swap_enter_dead(s, SWAP_FAILURE_TIMEOUT); } break; case SWAP_ACTIVATING_SIGKILL: case SWAP_DEACTIVATING_SIGKILL: - log_warning_unit(UNIT(s)->id, "%s swap process still around after SIGKILL. Ignoring.", UNIT(s)->id); + log_unit_warning(UNIT(s)->id, "%s swap process still around after SIGKILL. Ignoring.", UNIT(s)->id); swap_enter_dead(s, SWAP_FAILURE_TIMEOUT); break; diff --git a/src/core/timer.c b/src/core/timer.c index 5c4e9f995a..1380443419 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -86,7 +86,7 @@ static int timer_verify(Timer *t) { return 0; if (!t->values) { - log_error_unit(UNIT(t)->id, "%s lacks value setting. Refusing.", UNIT(t)->id); + log_unit_error(UNIT(t)->id, "%s lacks value setting. Refusing.", UNIT(t)->id); return -EINVAL; } @@ -260,7 +260,7 @@ static void timer_set_state(Timer *t, TimerState state) { } if (state != old_state) - log_debug_unit(UNIT(t)->id, + log_unit_debug(UNIT(t)->id, "%s changed %s -> %s", UNIT(t)->id, timer_state_to_string(old_state), timer_state_to_string(state)); @@ -419,7 +419,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { } if (!found_monotonic && !found_realtime) { - log_debug_unit(UNIT(t)->id, "%s: Timer is elapsed.", UNIT(t)->id); + log_unit_debug(UNIT(t)->id, "%s: Timer is elapsed.", UNIT(t)->id); timer_set_state(t, TIMER_ELAPSED); return; } @@ -427,7 +427,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { if (found_monotonic) { char buf[FORMAT_TIMESPAN_MAX]; - log_debug_unit(UNIT(t)->id, "%s: Monotonic timer elapses in %s.", + log_unit_debug(UNIT(t)->id, "%s: Monotonic timer elapses in %s.", UNIT(t)->id, format_timespan(buf, sizeof(buf), t->next_elapse_monotonic_or_boottime > ts_monotonic ? t->next_elapse_monotonic_or_boottime - ts_monotonic : 0, 0)); @@ -456,7 +456,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { if (found_realtime) { char buf[FORMAT_TIMESTAMP_MAX]; - log_debug_unit(UNIT(t)->id, "%s: Realtime timer elapses at %s.", UNIT(t)->id, format_timestamp(buf, sizeof(buf), t->next_elapse_realtime)); + log_unit_debug(UNIT(t)->id, "%s: Realtime timer elapses at %s.", UNIT(t)->id, format_timestamp(buf, sizeof(buf), t->next_elapse_realtime)); if (t->realtime_event_source) { r = sd_event_source_set_time(t->realtime_event_source, t->next_elapse_realtime); @@ -485,7 +485,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { return; fail: - log_warning_unit(UNIT(t)->id, "%s failed to enter waiting state: %s", UNIT(t)->id, strerror(-r)); + log_unit_warning(UNIT(t)->id, "%s failed to enter waiting state: %s", UNIT(t)->id, strerror(-r)); timer_enter_dead(t, TIMER_FAILURE_RESOURCES); } @@ -513,7 +513,7 @@ static void timer_enter_running(Timer *t) { return; fail: - log_warning_unit(UNIT(t)->id, + log_unit_warning(UNIT(t)->id, "%s failed to queue unit startup job: %s", UNIT(t)->id, bus_error_message(&error, r)); timer_enter_dead(t, TIMER_FAILURE_RESOURCES); @@ -596,7 +596,7 @@ static int timer_deserialize_item(Unit *u, const char *key, const char *value, F state = timer_state_from_string(value); if (state < 0) - log_debug_unit(u->id, "Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else t->deserialized_state = state; } else if (streq(key, "result")) { @@ -604,23 +604,23 @@ static int timer_deserialize_item(Unit *u, const char *key, const char *value, F f = timer_result_from_string(value); if (f < 0) - log_debug_unit(u->id, "Failed to parse result value %s", value); + log_unit_debug(u->id, "Failed to parse result value %s", value); else if (f != TIMER_SUCCESS) t->result = f; } else if (streq(key, "last-trigger-realtime")) { r = safe_atou64(value, &t->last_trigger.realtime); if (r < 0) - log_debug_unit(u->id, "Failed to parse last-trigger-realtime value %s", value); + log_unit_debug(u->id, "Failed to parse last-trigger-realtime value %s", value); } else if (streq(key, "last-trigger-monotonic")) { r = safe_atou64(value, &t->last_trigger.monotonic); if (r < 0) - log_debug_unit(u->id, "Failed to parse last-trigger-monotonic value %s", value); + log_unit_debug(u->id, "Failed to parse last-trigger-monotonic value %s", value); } else - log_debug_unit(u->id, "Unknown serialization key '%s'", key); + log_unit_debug(u->id, "Unknown serialization key '%s'", key); return 0; } @@ -645,7 +645,7 @@ static int timer_dispatch(sd_event_source *s, uint64_t usec, void *userdata) { if (t->state != TIMER_WAITING) return 0; - log_debug_unit(UNIT(t)->id, "Timer elapsed on %s", UNIT(t)->id); + log_unit_debug(UNIT(t)->id, "Timer elapsed on %s", UNIT(t)->id); timer_enter_running(t); return 0; } @@ -678,7 +678,7 @@ static void timer_trigger_notify(Unit *u, Unit *other) { case TIMER_RUNNING: if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) { - log_debug_unit(UNIT(t)->id, "%s got notified about unit deactivation.", UNIT(t)->id); + log_unit_debug(UNIT(t)->id, "%s got notified about unit deactivation.", UNIT(t)->id); timer_enter_waiting(t, false); } break; @@ -711,7 +711,7 @@ static void timer_time_change(Unit *u) { if (t->state != TIMER_WAITING) return; - log_debug_unit(u->id, "%s: time change, recalculating next elapse.", u->id); + log_unit_debug(u->id, "%s: time change, recalculating next elapse.", u->id); timer_enter_waiting(t, false); } diff --git a/src/core/transaction.c b/src/core/transaction.c index 6ad11b2fdb..652ac71094 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -189,11 +189,11 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *j) { * another unit in which case we * rather remove the start. */ - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "Looking at job %s/%s conflicted_by=%s", j->unit->id, job_type_to_string(j->type), yes_no(j->type == JOB_STOP && job_is_conflicted_by(j))); - log_debug_unit(k->unit->id, + log_unit_debug(k->unit->id, "Looking at job %s/%s conflicted_by=%s", k->unit->id, job_type_to_string(k->type), yes_no(k->type == JOB_STOP && job_is_conflicted_by(k))); @@ -222,7 +222,7 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *j) { return -ENOEXEC; /* Ok, we can drop one, so let's do so. */ - log_debug_unit(d->unit->id, + log_unit_debug(d->unit->id, "Fixing conflicting jobs %s/%s,%s/%s by deleting job %s/%s", j->unit->id, job_type_to_string(j->type), k->unit->id, job_type_to_string(k->type), @@ -368,7 +368,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi * job to remove. We use the marker to find our way * back, since smart how we are we stored our way back * in there. */ - log_warning_unit(j->unit->id, + log_unit_warning(j->unit->id, "Found ordering cycle on %s/%s", j->unit->id, job_type_to_string(j->type)); @@ -376,7 +376,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) { /* logging for j not k here here to provide consistent narrative */ - log_warning_unit(j->unit->id, + log_unit_warning(j->unit->id, "Found dependency on %s/%s", k->unit->id, job_type_to_string(k->type)); @@ -396,10 +396,10 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi if (delete) { /* logging for j not k here here to provide consistent narrative */ - log_warning_unit(j->unit->id, + log_unit_warning(j->unit->id, "Breaking ordering cycle by deleting job %s/%s", delete->unit->id, job_type_to_string(delete->type)); - log_error_unit(delete->unit->id, + log_unit_error(delete->unit->id, "Job %s/%s deleted to break ordering cycle starting with %s/%s", delete->unit->id, job_type_to_string(delete->type), j->unit->id, job_type_to_string(j->type)); @@ -552,17 +552,17 @@ rescan: continue; if (stops_running_service) - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "%s/%s would stop a running service.", j->unit->id, job_type_to_string(j->type)); if (changes_existing_job) - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "%s/%s would change existing job.", j->unit->id, job_type_to_string(j->type)); /* Ok, let's get rid of this */ - log_debug_unit(j->unit->id, + log_unit_debug(j->unit->id, "Deleting %s/%s to minimize impact.", j->unit->id, job_type_to_string(j->type)); @@ -819,7 +819,7 @@ static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependen job_dependency_free(j->object_list); if (other && delete_dependencies) { - log_debug_unit(other->unit->id, + log_unit_debug(other->unit->id, "Deleting job %s/%s as dependency of job %s/%s", other->unit->id, job_type_to_string(other->type), j->unit->id, job_type_to_string(j->type)); @@ -915,7 +915,7 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, following, i) { r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, override, false, false, ignore_order, e); if (r < 0) { - log_warning_unit(dep->id, + log_unit_warning(dep->id, "Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error_message(e, r)); @@ -954,7 +954,8 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES_OVERRIDABLE], i) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, !override, override, false, false, ignore_order, e); if (r < 0) { - log_full_unit(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, dep->id, + log_unit_full(dep->id, + r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, "Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error_message(e, r)); @@ -966,7 +967,8 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, false, ignore_order, e); if (r < 0) { - log_full_unit(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, dep->id, + log_unit_full(dep->id, + r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, "Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error_message(e, r)); @@ -989,7 +991,8 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE_OVERRIDABLE], i) { r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, false, ignore_order, e); if (r < 0) { - log_full_unit(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, dep->id, + log_unit_full(dep->id, + r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, "Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error_message(e, r)); @@ -1012,7 +1015,7 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i) { r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, override, false, false, ignore_order, e); if (r < 0) { - log_warning_unit(dep->id, + log_unit_warning(dep->id, "Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error_message(e, r)); @@ -1065,7 +1068,7 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATES_RELOAD_TO], i) { r = transaction_add_job_and_dependencies(tr, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e); if (r < 0) { - log_warning_unit(dep->id, + log_unit_warning(dep->id, "Cannot add dependency reload job for unit %s, ignoring: %s", dep->id, bus_error_message(e, r)); @@ -1112,7 +1115,7 @@ int transaction_add_isolate_jobs(Transaction *tr, Manager *m) { r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, tr->anchor_job, true, false, false, false, false, NULL); if (r < 0) - log_warning_unit(u->id, + log_unit_warning(u->id, "Cannot add isolate job for unit %s, ignoring: %s", u->id, strerror(-r)); } diff --git a/src/core/unit.c b/src/core/unit.c index 948f8e21bd..2e8df7d8d8 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1218,7 +1218,7 @@ int unit_load(Unit *u) { goto fail; if (u->on_failure_job_mode == JOB_ISOLATE && set_size(u->dependencies[UNIT_ON_FAILURE]) > 1) { - log_error_unit(u->id, "More than one OnFailure= dependencies specified for %s but OnFailureJobMode=isolate set. Refusing.", u->id); + log_unit_error(u->id, "More than one OnFailure= dependencies specified for %s but OnFailureJobMode=isolate set. Refusing.", u->id); r = -EINVAL; goto fail; } @@ -1239,7 +1239,7 @@ fail: unit_add_to_dbus_queue(u); unit_add_to_gc_queue(u); - log_debug_unit(u->id, "Failed to load configuration for %s: %s", + log_unit_debug(u->id, "Failed to load configuration for %s: %s", u->id, strerror(-r)); return r; @@ -1264,7 +1264,7 @@ static bool unit_condition_test_list(Unit *u, Condition *first, const char *(*to r = condition_test(c); if (r < 0) - log_warning_unit(u->id, + log_unit_warning(u->id, "Couldn't determine result for %s=%s%s%s for %s, assuming failed: %s", to_string(c->type), c->trigger ? "|" : "", @@ -1273,7 +1273,7 @@ static bool unit_condition_test_list(Unit *u, Condition *first, const char *(*to u->id, strerror(-r)); else - log_debug_unit(u->id, + log_unit_debug(u->id, "%s=%s%s%s %s for %s.", to_string(c->type), c->trigger ? "|" : "", @@ -1394,7 +1394,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) { t == JOB_STOP ? SD_MESSAGE_UNIT_STOPPING : SD_MESSAGE_UNIT_RELOADING; - log_struct_unit(LOG_INFO, + log_unit_struct(LOG_INFO, u->id, MESSAGE_ID(mid), "MESSAGE=%s", buf, @@ -1431,21 +1431,21 @@ int unit_start(Unit *u) { * but we don't want to recheck the condition in that case. */ if (state != UNIT_ACTIVATING && !unit_condition_test(u)) { - log_debug_unit(u->id, "Starting of %s requested but condition failed. Not starting unit.", u->id); + log_unit_debug(u->id, "Starting of %s requested but condition failed. Not starting unit.", u->id); return -EALREADY; } /* If the asserts failed, fail the entire job */ if (state != UNIT_ACTIVATING && !unit_assert_test(u)) { - log_debug_unit(u->id, "Starting of %s requested but asserts failed.", u->id); + log_unit_debug(u->id, "Starting of %s requested but asserts failed.", u->id); return -EPROTO; } /* Forward to the main object, if we aren't it. */ following = unit_following(u); if (following) { - log_debug_unit(u->id, "Redirecting start request from %s to %s.", u->id, following->id); + log_unit_debug(u->id, "Redirecting start request from %s to %s.", u->id, following->id); return unit_start(following); } @@ -1496,7 +1496,7 @@ int unit_stop(Unit *u) { return -EALREADY; if ((following = unit_following(u))) { - log_debug_unit(u->id, "Redirecting stop request from %s to %s.", + log_unit_debug(u->id, "Redirecting stop request from %s to %s.", u->id, following->id); return unit_stop(following); } @@ -1534,14 +1534,14 @@ int unit_reload(Unit *u) { return -EALREADY; if (state != UNIT_ACTIVE) { - log_warning_unit(u->id, "Unit %s cannot be reloaded because it is inactive.", + log_unit_warning(u->id, "Unit %s cannot be reloaded because it is inactive.", u->id); return -ENOEXEC; } following = unit_following(u); if (following) { - log_debug_unit(u->id, "Redirecting reload request from %s to %s.", + log_unit_debug(u->id, "Redirecting reload request from %s to %s.", u->id, following->id); return unit_reload(following); } @@ -1595,7 +1595,7 @@ static void unit_check_unneeded(Unit *u) { if (unit_active_or_pending(other)) return; - log_info_unit(u->id, "Unit %s is not needed anymore. Stopping.", u->id); + log_unit_info(u->id, "Unit %s is not needed anymore. Stopping.", u->id); /* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */ manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL); @@ -1627,7 +1627,7 @@ static void unit_check_binds_to(Unit *u) { if (!stop) return; - log_info_unit(u->id, "Unit %s is bound to inactive service. Stopping, too.", u->id); + log_unit_info(u->id, "Unit %s is bound to inactive service. Stopping, too.", u->id); /* A unit we need to run is gone. Sniff. Let's stop this. */ manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL); @@ -1719,14 +1719,14 @@ void unit_start_on_failure(Unit *u) { if (set_size(u->dependencies[UNIT_ON_FAILURE]) <= 0) return; - log_info_unit(u->id, "Triggering OnFailure= dependencies of %s.", u->id); + log_unit_info(u->id, "Triggering OnFailure= dependencies of %s.", u->id); SET_FOREACH(other, u->dependencies[UNIT_ON_FAILURE], i) { int r; r = manager_add_job(u->manager, JOB_START, other, u->on_failure_job_mode, true, NULL, NULL); if (r < 0) - log_error_unit(u->id, "Failed to enqueue OnFailure= job: %s", strerror(-r)); + log_unit_error(u->id, "Failed to enqueue OnFailure= job: %s", strerror(-r)); } } @@ -1890,7 +1890,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su check_unneeded_dependencies(u); if (ns != os && ns == UNIT_FAILED) { - log_notice_unit(u->id, "Unit %s entered failed state.", u->id); + log_unit_notice(u->id, "Unit %s entered failed state.", u->id); unit_start_on_failure(u); } } @@ -2152,10 +2152,10 @@ static int maybe_warn_about_dependency(const char *id, const char *other, UnitDe case UNIT_TRIGGERS: case UNIT_TRIGGERED_BY: if (streq_ptr(id, other)) - log_warning_unit(id, "Dependency %s=%s dropped from unit %s", + log_unit_warning(id, "Dependency %s=%s dropped from unit %s", unit_dependency_to_string(dependency), id, other); else - log_warning_unit(id, "Dependency %s=%s dropped from unit %s merged into %s", + log_unit_warning(id, "Dependency %s=%s dropped from unit %s merged into %s", unit_dependency_to_string(dependency), id, strna(other), id); return -EINVAL; @@ -3435,7 +3435,7 @@ int unit_kill_context( _cleanup_free_ char *comm = NULL; get_process_comm(main_pid, &comm); - log_warning_unit(u->id, "Failed to kill main process " PID_FMT " (%s): %s", main_pid, strna(comm), strerror(-r)); + log_unit_warning(u->id, "Failed to kill main process " PID_FMT " (%s): %s", main_pid, strna(comm), strerror(-r)); } else { if (!main_pid_alien) wait_for_exit = true; @@ -3452,7 +3452,7 @@ int unit_kill_context( _cleanup_free_ char *comm = NULL; get_process_comm(control_pid, &comm); - log_warning_unit(u->id, "Failed to kill control process " PID_FMT " (%s): %s", control_pid, strna(comm), strerror(-r)); + log_unit_warning(u->id, "Failed to kill control process " PID_FMT " (%s): %s", control_pid, strna(comm), strerror(-r)); } else { wait_for_exit = true; @@ -3472,7 +3472,7 @@ int unit_kill_context( r = cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, sig, true, true, false, pid_set); if (r < 0) { if (r != -EAGAIN && r != -ESRCH && r != -ENOENT) - log_warning_unit(u->id, "Failed to kill control group: %s", strerror(-r)); + log_unit_warning(u->id, "Failed to kill control group: %s", strerror(-r)); } else if (r > 0) { /* FIXME: For now, we will not wait for the diff --git a/src/core/unit.h b/src/core/unit.h index 54ba11a889..5c0fba7cf2 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -596,13 +596,13 @@ UnitActiveState unit_active_state_from_string(const char *s) _pure_; /* Macros which append UNIT= or USER_UNIT= to the message */ -#define log_full_unit(level, unit, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__) -#define log_full_unit_errno(level, error, unit, ...) log_meta_object(level, error, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__) +#define log_unit_full_errno(unit, level, error, ...) log_object_internal(level, error, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__) +#define log_unit_full(unit, level, ...) log_unit_full_errno(unit, level, 0, __VA_ARGS__) -#define log_debug_unit(unit, ...) log_full_unit(LOG_DEBUG, unit, __VA_ARGS__) -#define log_info_unit(unit, ...) log_full_unit(LOG_INFO, unit, __VA_ARGS__) -#define log_notice_unit(unit, ...) log_full_unit(LOG_NOTICE, unit, __VA_ARGS__) -#define log_warning_unit(unit, ...) log_full_unit(LOG_WARNING, unit, __VA_ARGS__) -#define log_error_unit(unit, ...) log_full_unit(LOG_ERR, unit, __VA_ARGS__) +#define log_unit_debug(unit, ...) log_unit_full(unit, LOG_DEBUG, __VA_ARGS__) +#define log_unit_info(unit, ...) log_unit_full(unit, LOG_INFO, __VA_ARGS__) +#define log_unit_notice(unit, ...) log_unit_full(unit, LOG_NOTICE, __VA_ARGS__) +#define log_unit_warning(unit, ...) log_unit_full(unit, LOG_WARNING, __VA_ARGS__) +#define log_unit_error(unit, ...) log_unit_full(unit, LOG_ERR, __VA_ARGS__) -#define log_struct_unit(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__) +#define log_unit_struct(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__) |