Skip to content

wptagent log local logs syslog rfc5424 #638

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

Merged
merged 6 commits into from
Sep 22, 2023

Conversation

FedericoMulas
Copy link
Contributor

@FedericoMulas FedericoMulas commented Sep 6, 2023

ref 177487

  • Added log handler for syslog rfc5424 to support structured logging, ported from https://github.com/jobec/rfc5424-logging-handler/tree/master with BSD license because seems frozen and had needed issues pending (only 2 files where needed).
  • Added new RotatedFileTransport(StreamTransport) in internal\rfc5424logging\transport.py to support an external tool rotating the log file (e.g. logrotate, logstash, etc.).
  • Added new file rfc5424logging_context.py and relative class LoggingContext to store structured logging context to enhance each log while keeping backward compatibility with other types of logs.
    * Added additional option --loglevel and refactored log level option handling into setup_logging class to support current log format an the new introduced rfc5424 log format.
  • Added additional option --logformat and refactored log level option handling into setup_logging class to support. It reuse --verbose option and --log to set the log file path and verbosity. Only supports new introduced rfc5424 log format syslog.

After this PR is approved all log entries will be updated to add the new logging context.

@mjkozicki
Copy link
Contributor

@pmeenan If you could take a look, thanks.

Copy link
Contributor

@pmeenan pmeenan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM but the flag behavior is a bit confusing. It might be cleaner to always use verbosity to set the log level and just use a different flag to switch logging into Rfc 5424 mode. That way log file and verbosity params would be consistent. I'm good either way though.

wptagent.py Outdated
# logging_level has priority over other parameters.
# When specified the logging to file will be the only allowed type of logging.
# Must be used in conjunction with log_file.
if logging_level != None and log_file != None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, is not None is core consistent python with the existing code
if logging_level is not None and log_file is not None:

@FedericoMulas
Copy link
Contributor Author

@pmeenan I refactored as suggested, works well too.

@mjkozicki mjkozicki merged commit 075ca79 into catchpoint:master Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants