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

Using structured logging in the interceptor #182

Closed
wants to merge 7 commits into from

Conversation

arschles
Copy link
Collaborator

Instead of using the standard library's log package in the interceptor, this PR uses klogr, a logr implementation for the klogr library that we already depend on in this repository.

The advantages of using this library -- and structured logging in general -- over the std lib log package are:

  • we pass a logger around for functions to use, which can "subclass" them (using .WithName, WithValues) to their needs
  • since we're using logr, we can swap out the underlying implementation to adapters for other underlying log libraries if we want
  • we can log different lines at different levels
  • we log variable data in a structured format, rather than in format strings
  • we can log data to multiple locations using klog

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO)
  • Any necessary documentation is added, such as:

Fixes #

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
@arschles arschles added the enhancement New feature or request label Jun 15, 2021
Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
return func() error {
deployment, err := deployCache.Get(deployName)
if err != nil {
// if we didn't get the initial deployment state, bail out
return fmt.Errorf("Error getting state for deployment %s (%s)", deployName, err)
logger.Error(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this block is significantly changed in https://github.com/kedacore/http-add-on/pull/181/files. The conflict should be resolved favoring the other PR

arschles and others added 3 commits June 16, 2021 10:57
Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
@arschles arschles enabled auto-merge (squash) June 16, 2021 20:07
@arschles
Copy link
Collaborator Author

This will be superseded by #206. Closing

@arschles arschles closed this Jul 23, 2021
auto-merge was automatically disabled July 23, 2021 17:00

Pull request was closed

@arschles arschles deleted the interceptor-logs branch July 23, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant