diff options
author | Mirco Tischler <mt-ml@gmx.de> | 2013-01-17 18:55:06 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-01-18 11:14:00 -0500 |
commit | bbc9006e6b5665073149331d75c104a33224dc19 (patch) | |
tree | 116572d108aaa170449fa8eb9617980e77a238b6 | |
parent | ef1673d16907726d83bdff2e57b5261997a85020 (diff) |
core: log USER_UNIT instead of UNIT if in user session
-rw-r--r-- | src/core/execute.c | 12 | ||||
-rw-r--r-- | src/core/job.c | 16 | ||||
-rw-r--r-- | src/core/mount.c | 4 | ||||
-rw-r--r-- | src/core/service.c | 4 | ||||
-rw-r--r-- | src/core/unit.c | 8 | ||||
-rw-r--r-- | src/core/unit.h | 5 |
6 files changed, 26 insertions, 23 deletions
diff --git a/src/core/execute.c b/src/core/execute.c index 9718e43a70..65a10af3b0 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1024,8 +1024,8 @@ int exec_spawn(ExecCommand *command, r = exec_context_load_environment(context, &files_env); if (r < 0) { - log_struct(LOG_ERR, - "UNIT=%s", unit_id, + log_struct_unit(LOG_ERR, + unit_id, "MESSAGE=Failed to load environment files: %s", strerror(-r), "ERRNO=%d", -r, NULL); @@ -1039,8 +1039,8 @@ int exec_spawn(ExecCommand *command, if (!line) return log_oom(); - log_struct(LOG_DEBUG, - "UNIT=%s", unit_id, + log_struct_unit(LOG_DEBUG, + unit_id, "MESSAGE=About to execute %s", line, NULL); free(line); @@ -1512,8 +1512,8 @@ int exec_spawn(ExecCommand *command, _exit(r); } - log_struct(LOG_DEBUG, - "UNIT=%s", unit_id, + log_struct_unit(LOG_DEBUG, + unit_id, "MESSAGE=Forked %s as %lu", command->path, (unsigned long) pid, NULL); diff --git a/src/core/job.c b/src/core/job.c index 31ab11880e..e381ea2b69 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -713,25 +713,25 @@ 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(result == JOB_DONE ? LOG_INFO : LOG_ERR, + log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR, + u->id, MESSAGE_ID(mid), - "UNIT=%s", u->id, "RESULT=%s", job_result_to_string(result), "MESSAGE=%s", buf, NULL); } else if (t == JOB_STOP) - log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR, + log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR, + u->id, MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED), - "UNIT=%s", u->id, "RESULT=%s", job_result_to_string(result), "MESSAGE=%s", buf, NULL); else if (t == JOB_RELOAD) - log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR, + log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR, + u->id, MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED), - "UNIT=%s", u->id, "RESULT=%s", job_result_to_string(result), "MESSAGE=%s", buf, NULL); @@ -818,8 +818,8 @@ 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(LOG_NOTICE, - "UNIT=%s", u->id, + log_struct_unit(LOG_NOTICE, + u->id, "JOB_TYPE=%s", job_type_to_string(t), "JOB_RESULT=%s", job_result_to_string(result), "Job %s/%s failed with result '%s'.", diff --git a/src/core/mount.c b/src/core/mount.c index 25bc7e197a..18ce73b438 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -955,11 +955,11 @@ fail: void warn_if_dir_nonempty(const char *unit, const char* where) { if (dir_is_empty(where) > 0) return; - log_struct(LOG_NOTICE, + log_struct_unit(LOG_NOTICE, + unit, "MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.", unit, where, "WHERE=%s", where, - "_SYSTEMD_UNIT=%s", unit, MESSAGE_ID(SD_MESSAGE_OVERMOUNTING), NULL); } diff --git a/src/core/service.c b/src/core/service.c index 9e46dbae94..bc41617bf7 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2939,13 +2939,13 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { f = SERVICE_SUCCESS; } - log_struct(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE, + log_struct_unit(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, strna(code == CLD_EXITED ? exit_status_to_string(status, EXIT_STATUS_FULL) : signal_to_string(status)), - "UNIT=%s", u->id, "EXIT_CODE=%s", sigchld_code_to_string(code), "EXIT_STATUS=%i", status, NULL); diff --git a/src/core/unit.c b/src/core/unit.c index d26f6e456c..83359e126b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1022,9 +1022,9 @@ 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(LOG_INFO, + log_struct_unit(LOG_INFO, + u->id, MESSAGE_ID(mid), - "UNIT=%s", u->id, "MESSAGE=%s", buf, NULL); } @@ -1438,9 +1438,9 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su check_unneeded_dependencies(u); if (ns != os && ns == UNIT_FAILED) { - log_struct(LOG_NOTICE, + log_struct_unit(LOG_NOTICE, + u->id, "MESSAGE=Unit %s entered failed state", u->id, - "UNIT=%s", u->id, NULL); unit_trigger_on_failure(u); } diff --git a/src/core/unit.h b/src/core/unit.h index d1ecae74ac..23cd9ef459 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -23,6 +23,7 @@ #include <stdbool.h> #include <stdlib.h> +#include <unistd.h> typedef struct Unit Unit; typedef struct UnitVTable UnitVTable; @@ -556,9 +557,11 @@ UnitActiveState unit_active_state_from_string(const char *s); const char *unit_dependency_to_string(UnitDependency i); UnitDependency unit_dependency_from_string(const char *s); -#define log_full_unit(level, unit, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "UNIT=", unit, __VA_ARGS__) +#define log_full_unit(level, unit, ...) log_meta_object(level, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __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_struct_unit(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__) |