add context to logs, set default log level to info #121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's in this PR?
This PR aims to begin refactoring nifikop logging to be much less verbose and more informational. Specifically, I attempted to do all of the following in this PR:
log.Info(fmt.Sprintf("..."))
occurrences tolog.Info("...", zap.String("...", var))
NifiCluster
the log is in relation to,nodeId
, k8s object name or namespace, etc.I've identified several other areas that warrant refactoring to clean up logs, but will leave these for later PRs to keep PR scope small.
For example, the below link refers to this
RequeueWithError()
method, which is called 500+ times as a result of an error but it logs all of the error messages at theInfo
level. There's no context for what the error was, so it's not possible to know what context should be added to the log. Callers right now provide a parameter that's formatted withfmt.Sprintf("...")
, but we can make use of the zap lib to consistently log errors. Callers should log the context for the error and then requeue the request.https://github.com/konpyutaika/nifikop/blob/v0.11.0-release/controllers/controller_common.go#L24-L28
Why?
This is a part of a larger effort to increase the quality of logs generated by nifikop.
Checklist