Skip to content

Commit

Permalink
[RSPEED-408] Add audit logging to stdout (#99)
Browse files Browse the repository at this point in the history
* Fix config.toml for release and devel path

* Add audit logging to sys.stdout
  • Loading branch information
r0x0d authored Jan 7, 2025
1 parent f9ea988 commit 276e0ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
16 changes: 14 additions & 2 deletions command_line_assistant/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@
"formatter": "audit",
"mode": "a",
},
"audit_journald": {
"class": "logging.StreamHandler",
"formatter": "audit",
"stream": "ext://sys.stdout",
},
},
"loggers": {
"root": {"handlers": ["console"], "level": "DEBUG"},
"audit": {
"handlers": ["audit_file", "console"],
"handlers": ["audit_file", "audit_journald"],
"level": "INFO",
"propagate": False,
},
Expand Down Expand Up @@ -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
Expand All @@ -118,7 +130,7 @@ def _create_audit_formatter(config: Config) -> AuditFormatter:
"""

fmt = '{"timestamp": "%(asctime)s", "user": "%(user)s", "message": "%(message)s"%(query)s%(response)s}'
datefmt = "%Y-%m-%dT%H:%M:%S.%fZ"
datefmt = "%Y-%m-%dT%H:%M:%S"
return AuditFormatter(config=config, fmt=fmt, datefmt=datefmt)


Expand Down
16 changes: 1 addition & 15 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 276e0ca

Please sign in to comment.