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

Add ZapLogger with option to disable stacktraces #47

Closed
wants to merge 3 commits into from

Conversation

turkenh
Copy link
Member

@turkenh turkenh commented Oct 10, 2019

Signed-off-by: Hasan Turken turkenh@gmail.com

Description of your changes

This PR is to show how stacktraces could be disabled with current revision of controller runtime. If we update controller runtime, we need to implement like in crossplane-contrib/provider-gcp#49

Related to: Related crossplane/crossplane#529

Checklist

I have:

  • Run make reviewable to ensure this PR is ready for review.
  • Ensured this PR contains a neat, self documenting set of commits.
  • Updated any relevant documentation, examples, or release notes.
  • Updated the RBAC permissions in clusterrole.yaml to include any new types.

Signed-off-by: Hasan Turken <turkenh@gmail.com>
// config will be used (stacktraces on errors, sampling).
// If disableStacktrace is true, stacktraces enabled on fatals
// independent of config.
func zapLogger(development bool, disableStacktrace bool) logr.Logger {
Copy link
Member

Choose a reason for hiding this comment

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

as discussed in crossplane-contrib/provider-gcp#49, I like the idea of having a common reusable way to get a logger that only does stack traces for fatal level. Can we continue pursuing that on this PR? If we finish and merge this one, then all consumer repos (main crossplane, GCP/AWS/Azure stacks) can just call this one single implementation.

func zapLogger(development bool, disableStacktrace bool) logr.Logger {
zl := runtimezap.RawLoggerTo(os.Stderr, development)

if disableStacktrace {
Copy link
Member

Choose a reason for hiding this comment

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

do you think this should use the new controller-runtime v0.2.2 way of initializing the logger? It is probably not worth updating the entire controller-runtime to just get the new logger initialization, but it could also be nice to get a new controller-runtime update anyways.

What is your opinion @turkenh?

Copy link
Member Author

Choose a reason for hiding this comment

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

As you noted, updating controller-runtime is not necessary for this specific issue but I agree that it make sense to bump controller-runtime to v0.2.2 which is latest v0.2, currently it is on v0.2.0-beta.5 which does not sound that stable :)
Still I'll go and ask on slack dev channel to make sure everyone is ok with this.

Signed-off-by: Hasan Turken <turkenh@gmail.com>
Signed-off-by: Hasan Turken <turkenh@gmail.com>
@turkenh turkenh marked this pull request as ready for review October 14, 2019 12:25
@turkenh turkenh requested a review from jbw976 October 14, 2019 12:25
@negz
Copy link
Member

negz commented Jan 27, 2020

I'm afraid I don't agree with @jbw976 regarding having crossplane-runtime provide helper code to produce correctly loggers. I'd rather keep any such code (which I imagine should be fairly succinct?) limited to main.go, where loggers should be instantiated and plumbed down to any controllers that use them. As of #108 crossplane-runtime is aware only of the interfaces it should use for logging; not what concrete implementation should be used.

How should we proceed with this PR? I personally don't feel anything is currently broken, so my vote would be to close it.

@jbw976 jbw976 closed this Feb 1, 2020
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