mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
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:
parent
c8f89e3ca5
commit
c2d5d1d3c8
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -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')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user