Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RSPEED-408] Add audit logging to stdout #99

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion config.toml
11 changes: 11 additions & 0 deletions data/release/xdg/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,16 @@ file = "/var/lib/command-line-assistant/history.json"
[backend]
endpoint = "http://localhost:8080"

[backend.auth]
# cert_file = "/etc/pki/consumer/cert.pem"
# key_file = "/etc/pki/consumer/key.pem"
# verify_ssl = true


[logging]
level = "DEBUG"
responses = true # Global setting - don't log responses by default
question = true # Global setting - don't log questions by default

# User-specific settings
# users.admin = { responses = true, question = true }
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.

Loading