]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log: open journal when cli program run in a service unit 17911/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Dec 2020 16:49:13 +0000 (01:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Dec 2020 05:44:02 +0000 (14:44 +0900)
Previously, cli programs like networkctl always use console for logging.

src/basic/log.c

index d2aaf08368aa2fd67fee490a7ef8dbc7a9ce1b69..dd9c7db18ba7bda18570e7cd5183f073a57a9aa0 100644 (file)
@@ -1484,7 +1484,9 @@ void log_setup_service(void) {
 void log_setup_cli(void) {
         /* Sets up logging the way it is most appropriate for running a program as a CLI utility. */
 
-        log_show_color(true);
+        log_set_target(LOG_TARGET_AUTO);
         log_parse_environment_cli();
         (void) log_open();
+        if (log_on_console() && show_color < 0)
+                log_show_color(true);
 }