-
Notifications
You must be signed in to change notification settings - Fork 1.9k
various: pass logger.Logf through to more places #7539
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
Conversation
control/controlhttp/client.go
Outdated
@@ -382,18 +383,27 @@ func (a *Dialer) dialURL(ctx context.Context, u *url.URL, addr netip.Addr) (*Cli | |||
func (a *Dialer) tryURLUpgrade(ctx context.Context, u *url.URL, addr netip.Addr, init []byte) (net.Conn, error) { | |||
var dns *dnscache.Resolver | |||
|
|||
// Maintain prior behaviour where passing no logger to |
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.
logf method instead?
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.
I intentionally didn't use that; the a.logf
method will drop logs if no a.Logf
option is specified, whereas the previous behaviour of dnscache.Resolver
always logs with log.Printf
if there's no logger specified.
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.
logfOrDefault method then? I just don't want to see a big comment and var decl/conditional in the middle of unrelated code
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.
I actually just changed this to use a.Logf
directly when constructing the Resolver
; this propagates nil-ness and retains the default "fall back to log.Printf" behaviour that dnscache.Resolver
has. PTAL?
7113915
to
74b3817
Compare
net/dnsfallback/dnsfallback.go
Outdated
func SetLogger(log logger.Logf) { | ||
logfunc.Store(log) | ||
// SetLogger sets the logging function that this package will use, and returns | ||
// the old value (which may be nil). The default logger if this function is not |
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.
The default value of the logger is log.Printf
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.
Yep, but the default value of the logfunc
is nil; the top-level logf
function will fall back to log.Printf
if so.
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.
The value defaults to log.Printf if not explicitly set?
74b3817
to
0555c82
Compare
Updates #7537 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Id89acab70ea678c8c7ff0f44792d54c7223337c6
0555c82
to
c4b1e3b
Compare
Updates #7537
Change-Id: Id89acab70ea678c8c7ff0f44792d54c7223337c6