-
Notifications
You must be signed in to change notification settings - Fork 101
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
contextual logging #597
contextual logging #597
Conversation
closes #469 - removing duplicit error message: `log.Err(err).Msgf("...(%s)",err)` I'm replacing with `log.Err(err).Msg("...")` - replacing with contextual message: `log.Info().Msgf("started provider (%s)",reconciler.DNSProvider.String)` I'm replacing with `log.Info().Str("provider", reconciler.DNSProvider.String()).Msg("started")` - I had to extend DNSProvider with Stringer interface. added String() string function Signed-off-by: kuritka <[email protected]>
5ef03ec
to
ea30cd1
Compare
} | ||
} | ||
return | ||
return targets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing against(I actually like this style more) but why are we returning explicitly now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, good point, mee too, BUT:
golangci-lint run
controllers/providers/assistant/gslb.go:330:2: naked return in func `GetExternalTargets` with 38 lines of code (nakedret)
return
^
make: *** [lint] Error 1
The linter basically says, the function is too large to have naked return (nakedret static analysis).
The function was prolonged by splitting the log messages into more lines
log.Warn().
Str("fqdn", fqdn).
Str("nameserver", nameserver).
Err(err).
Msg("Can't resolve FQDN using nameserver")
I had three options at the end: satisfy nakedret, refactor the function into two funcs, or leave the logs on one line?
Finally I decided to satisfy nakedret.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clear, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuritka LGTM!
closes #469
log.Err(err).Msgf("...(%s)",err)
I'm replacing withlog.Err(err).Msg("...")
log.Info().Msgf("started provider (%s)",reconciler.DNSProvider.String)
I'm replacing withlog.Info().Str("provider", reconciler.DNSProvider.String()).Msg("started")
Signed-off-by: kuritka [email protected]