static bool arg_with_timer = false;
static bool arg_quiet = false;
static bool arg_verbose = false;
+static OutputMode arg_output = _OUTPUT_MODE_INVALID;
static bool arg_aggressive_gc = false;
static char *arg_working_directory = NULL;
static char *arg_root_directory = NULL;
" -P --pipe Pass STDIN/STDOUT/STDERR directly to service\n"
" -q --quiet Suppress information messages during runtime\n"
" -v --verbose Show unit logs while executing operation\n"
+ " --output=STRING Controls formatting of verbose logs, see\n"
+ " journalctl for valid values\n"
" --json=pretty|short|off Print unit name and invocation id as JSON\n"
" -G --collect Unload unit after it ran, even when failed\n"
" -S --shell Invoke a $SHELL interactively\n"
ARG_EXEC_USER,
ARG_EXEC_GROUP,
ARG_NICE,
+ ARG_OUTPUT,
ARG_ON_ACTIVE,
ARG_ON_BOOT,
ARG_ON_STARTUP,
{ "pipe", no_argument, NULL, 'P' },
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
+ { "output", required_argument, NULL, ARG_OUTPUT },
{ "on-active", required_argument, NULL, ARG_ON_ACTIVE },
{ "on-boot", required_argument, NULL, ARG_ON_BOOT },
{ "on-startup", required_argument, NULL, ARG_ON_STARTUP },
arg_verbose = true;
break;
+ case ARG_OUTPUT:
+ if (streq(optarg, "help"))
+ return DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
+
+ arg_output = output_mode_from_string(optarg);
+ if (arg_output < 0)
+ return log_error_errno(arg_output, "Unknown output format '%s'.", optarg);
+ break;
+
case ARG_ON_ACTIVE:
r = add_timer_property("OnActiveSec", optarg);
if (r < 0)
_cleanup_(fork_notify_terminate) PidRef journal_pid = PIDREF_NULL;
if (arg_verbose)
- (void) journal_fork(arg_runtime_scope, STRV_MAKE(c.unit), &journal_pid);
+ (void) journal_fork(arg_runtime_scope, STRV_MAKE(c.unit), arg_output, &journal_pid);
r = bus_call_with_hint(bus, m, "service", &reply);
if (r < 0)
free(array);
}
-int journal_fork(RuntimeScope scope, char * const* units, PidRef *ret_pidref) {
+int journal_fork(RuntimeScope scope, char * const* units, OutputMode output, PidRef *ret_pidref) {
assert(scope >= 0);
assert(scope < _RUNTIME_SCOPE_MAX);
*u) < 0)
return log_oom_debug();
+ if (output >= 0)
+ if (strv_extendf(&argv, "--output=%s", output_mode_to_string(output)) < 0)
+ return log_oom_debug();
+
return fork_notify(argv, ret_pidref);
}
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "output-mode.h"
#include "shared-forward.h"
int fork_notify(char * const *argv, PidRef *ret_pidref);
void fork_notify_terminate_many(sd_event_source **array, size_t n);
-int journal_fork(RuntimeScope scope, char * const *units, PidRef *ret_pidref);
+int journal_fork(RuntimeScope scope, char * const *units, OutputMode output, PidRef *ret_pidref);