From 256bbd9b2795ea422d582ae318dabe0490ac3774 Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Tue, 7 Jan 2025 09:23:59 -0300 Subject: [PATCH] Add audit logging to sys.stdout --- command_line_assistant/logger.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/command_line_assistant/logger.py b/command_line_assistant/logger.py index 65ab45a..4984fdb 100644 --- a/command_line_assistant/logger.py +++ b/command_line_assistant/logger.py @@ -33,11 +33,16 @@ "formatter": "audit", "mode": "a", }, + "audit_journald": { + "class": "logging.StreamHandler", + "stream": "ext://sys.stdout", + "formatter": "audit", + }, }, "loggers": { "root": {"handlers": ["console"], "level": "DEBUG"}, "audit": { - "handlers": ["audit_file", "console"], + "handlers": ["audit_file", "audit_journald", "console"], "level": "INFO", "propagate": False, }, @@ -110,6 +115,13 @@ def format(self, record: logging.LogRecord) -> str: def _create_audit_formatter(config: Config) -> AuditFormatter: """Internal method to create a new audit formatter instance. + Note: + This appears to be not used, but the logging class will call this + function to initialize the formatter options for audit logger. + + Do not remove this function, only if there is a better idea on how to + do it. + Args: config (Config): The application configuration