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

log: add new log package that uses slog as global logger #1663

Conversation

jmontesi
Copy link
Contributor

@jmontesi jmontesi commented Nov 28, 2023

The log package provides top-level funtions for creating log records in four different log levels as well as some other helper functions to set up the logging parameters and create special log handlers.

Two slog handlers are created: the MultiHandler that allows distributing the logs to several io.Writer objects and the CustomHandler to produce the log output in a specifc format.

The checksdb.Check type is also modified to add two new fields: a logger and a log archive where the check's log will be stored. The check's logger has the two handlers described above chained, so that the log output is written to the log file and to the check's log archive.

A log file has been created with a default name cnf-test-log.

Only a couple of log lines have been produces using this new logger as an example. The bulk of the work for converting the old log lines so that they use the new package will be done in a separate change.

The log package provides top-level funtions for creating log records in
four different log levels as well as some other helper functions to
set up the logging parameters and create special log handlers.

Two slog handlers are created: the MultiHandler that allows distributing
the logs to several io.Writer objects and the CustomHandler to produce
the log output in a specifc format.

The certdb.Check type is also modified to add two new fields: a logger
and a log archive where the check's log will be stored. The check's
logger has the two handlers described above chained, so that the log
output is written to the log file and to the check's log archive.

A log file has been created with a default name cnf-test-log.

Only a couple of log lines have been produces using this new logger as
an example. The bulk of the work for converting the old log lines so
that they use the new package will be done in a separate change.
Copy link
Contributor

@greyerof greyerof left a comment

Choose a reason for hiding this comment

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

Looks good. I just left some suggestions.

internal/log/custom_handler.go Outdated Show resolved Hide resolved
internal/log/custom_handler.go Outdated Show resolved Hide resolved
internal/log/custom_handler.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@jmontesi jmontesi merged commit a712625 into redhat-best-practices-for-k8s:ginkgo_removal Dec 1, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants