systemctl: add --verbose mode

This commit is contained in:
Lennart Poettering
2025-05-13 15:39:57 +02:00
parent 744ca8f616
commit c8aff47a9c
4 changed files with 27 additions and 2 deletions
+11
View File
@@ -2348,6 +2348,17 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>
<listitem>
<para>Display unit log output while executing unit operations.</para>
<xi:include href="version-info.xml" xpointer="v258"/>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--no-warn</option></term>
+7 -1
View File
@@ -10,6 +10,7 @@
#include "bus-util.h"
#include "bus-wait-for-jobs.h"
#include "bus-wait-for-units.h"
#include "fork-journal.h"
#include "macro.h"
#include "special.h"
#include "string-util.h"
@@ -388,9 +389,13 @@ int verb_start(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to allocate unit watch context: %m");
}
_cleanup_(journal_terminate) PidRef journal_pid = PIDREF_NULL;
if (arg_marked)
ret = enqueue_marked_jobs(bus, w);
else
else {
if (arg_verbose)
(void) journal_fork(arg_runtime_scope, (const char**) names, &journal_pid);
STRV_FOREACH(name, names) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -404,6 +409,7 @@ int verb_start(int argc, char *argv[], void *userdata) {
return log_oom();
}
}
}
if (!arg_no_block) {
const char *extra_args[4];
+8 -1
View File
@@ -90,6 +90,7 @@ bool arg_show_types = false;
int arg_check_inhibitors = -1;
bool arg_dry_run = false;
bool arg_quiet = false;
bool arg_verbose = false;
bool arg_no_warn = false;
bool arg_full = false;
bool arg_recursive = false;
@@ -304,6 +305,7 @@ static int systemctl_help(void) {
" suspend-then-hibernate, hybrid-sleep, default,\n"
" rescue, emergency, and exit.\n"
" -q --quiet Suppress output\n"
" -v --verbose Show unit logs while executing operation\n"
" --no-warn Suppress several warnings shown by default\n"
" --wait For (re)start, wait until service stopped again\n"
" For is-system-running, wait until startup is completed\n"
@@ -510,6 +512,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
{ "dry-run", no_argument, NULL, ARG_DRY_RUN },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "no-warn", no_argument, NULL, ARG_NO_WARN },
{ "root", required_argument, NULL, ARG_ROOT },
{ "image", required_argument, NULL, ARG_IMAGE },
@@ -556,7 +559,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
/* We default to allowing interactive authorization only in systemctl (not in the legacy commands) */
arg_ask_password = true;
while ((c = getopt_long(argc, argv, "hC:t:p:P:alqfs:H:M:n:o:iTr.::", options, NULL)) >= 0)
while ((c = getopt_long(argc, argv, "hC:t:p:P:alqvfs:H:M:n:o:iTr.::", options, NULL)) >= 0)
switch (c) {
@@ -770,6 +773,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
case 'v':
arg_verbose = true;
break;
case 'f':
arg_force++;
break;
+1
View File
@@ -68,6 +68,7 @@ extern bool arg_show_types;
extern int arg_check_inhibitors;
extern bool arg_dry_run;
extern bool arg_quiet;
extern bool arg_verbose;
extern bool arg_no_warn;
extern bool arg_full;
extern bool arg_recursive;