From c2d5d1d3c81374a1a45f27d9ec874bc179c16623 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 16 Sep 2025 14:10:08 -0700 Subject: [PATCH] privileged_daemon: Fix showing errors for freedombox-cmd command Tests: - When arguments are not provided to freedombox-cmd it shows errors on the console. - When a command is successfully executed, the output is printed on the console. - The output of the privileged daemon goes to the journald. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/log.py | 9 ++++++--- plinth/privileged_daemon.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plinth/log.py b/plinth/log.py index e34a02f47..d77a66d5d 100644 --- a/plinth/log.py +++ b/plinth/log.py @@ -90,13 +90,16 @@ def _capture_warnings(): warnings.filterwarnings('default', '', ImportWarning) -def action_init(): +def action_init(console: bool = False): """Initialize logging for action scripts.""" _capture_warnings() configuration = get_configuration() - # Don't log to console - configuration['root']['handlers'] = ['journal'] + if console: + configuration['root']['handlers'] = ['console'] + else: + configuration['root']['handlers'] = ['journal'] + logging.config.dictConfig(configuration) diff --git a/plinth/privileged_daemon.py b/plinth/privileged_daemon.py index 7cfd256a5..66102718e 100644 --- a/plinth/privileged_daemon.py +++ b/plinth/privileged_daemon.py @@ -207,7 +207,7 @@ class Server(socketserver.ThreadingUnixStreamServer): def client_main() -> None: """Parse arguments for the client for privileged daemon.""" - log.action_init() + log.action_init(console=True) parser = argparse.ArgumentParser() parser.add_argument('module', help='Module to trigger action in')