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 <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2025-09-29 16:58:41 +03:00
1 parent c8f89e3ca5
commit c2d5d1d3c8
2 files changed
+7 -4

No files matched your search

+6 -3
View File
@@ -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)
+1 -1
View File
@@ -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')