From: Lennart Poettering Date: Wed, 27 Nov 2019 11:13:59 +0000 (+0100) Subject: systemctl: show logs for correct namespace of service X-Git-Tag: v245-rc1~41^2~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d93dda3afef4d8bfae8e4d20122adfa5e2cc41f8;p=thirdparty%2Fsystemd.git systemctl: show logs for correct namespace of service --- diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 6fea2c9e33d..2e39f557632 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -576,6 +576,7 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li show_journal_by_unit( stdout, i.scope, + NULL, arg_output, 0, i.timestamp.monotonic, @@ -660,6 +661,7 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) show_journal_by_unit( stdout, i.slice, + NULL, arg_output, 0, i.timestamp.monotonic, diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 2377416b440..61234582a34 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -626,6 +626,7 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) { show_journal_by_unit( stdout, i->unit, + NULL, arg_output, 0, i->timestamp.monotonic, diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index ce0a4acf9c8..605412aec51 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -1453,6 +1453,7 @@ int add_match_this_boot(sd_journal *j, const char *machine) { int show_journal_by_unit( FILE *f, const char *unit, + const char *log_namespace, OutputMode mode, unsigned n_columns, usec_t not_before, @@ -1473,7 +1474,7 @@ int show_journal_by_unit( if (how_many <= 0) return 0; - r = sd_journal_open(&j, journal_open_flags); + r = sd_journal_open_namespace(&j, log_namespace, journal_open_flags | SD_JOURNAL_INCLUDE_DEFAULT_NAMESPACE); if (r < 0) return log_error_errno(r, "Failed to open journal: %m"); diff --git a/src/shared/logs-show.h b/src/shared/logs-show.h index 1e0c4ea1464..345efa4b2bb 100644 --- a/src/shared/logs-show.h +++ b/src/shared/logs-show.h @@ -46,6 +46,7 @@ int add_matches_for_user_unit( int show_journal_by_unit( FILE *f, const char *unit, + const char *namespace, OutputMode mode, unsigned n_columns, usec_t not_before, diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 60872bc5373..5547058296a 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -4007,6 +4007,8 @@ typedef struct UnitStatusInfo { int exit_code, exit_status; + const char *log_namespace; + usec_t condition_timestamp; bool condition_result; LIST_HEAD(UnitCondition, conditions); @@ -4545,6 +4547,7 @@ static void print_status_info( show_journal_by_unit( stdout, i->id, + i->log_namespace, arg_output, 0, i->inactive_exit_timestamp_monotonic, @@ -5491,6 +5494,7 @@ static int show_one( { "ExecMainExitTimestamp", "t", NULL, offsetof(UnitStatusInfo, exit_timestamp) }, { "ExecMainCode", "i", NULL, offsetof(UnitStatusInfo, exit_code) }, { "ExecMainStatus", "i", NULL, offsetof(UnitStatusInfo, exit_status) }, + { "LogNamespace", "s", NULL, offsetof(UnitStatusInfo, log_namespace) }, { "ConditionTimestamp", "t", NULL, offsetof(UnitStatusInfo, condition_timestamp) }, { "ConditionResult", "b", NULL, offsetof(UnitStatusInfo, condition_result) }, { "Conditions", "a(sbbsi)", map_conditions, 0 },