Skip to content

Commit

Permalink
Some logging improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Mar 21, 2024
1 parent ebd2046 commit 2396e6c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (cl *Client) initLogger() {
logger = log.Default
}
if cl.config.Debug {
logger = logger.FilterLevel(log.Debug)
logger = logger.WithFilterLevel(log.Debug)
}
cl.logger = logger.WithValues(cl)
}
Expand Down Expand Up @@ -667,7 +667,7 @@ func DialFirst(ctx context.Context, addr string, dialers []Dialer) (res DialResu
func dialFromSocket(ctx context.Context, s Dialer, addr string) net.Conn {
c, err := s.Dial(ctx, addr)
if err != nil {
log.Levelf(log.Debug, "error dialing %q: %v", addr, err)
log.ContextLogger(ctx).Levelf(log.Debug, "error dialing %q: %v", addr, err)
}
// This is a bit optimistic, but it looks non-trivial to thread this through the proxy code. Set
// it now in case we close the connection forthwith. Note this is also done in the TCP dialer
Expand Down
2 changes: 1 addition & 1 deletion testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestingConfig(t testing.TB) *ClientConfig {
cfg.ListenPort = 0
cfg.KeepAliveTimeout = time.Millisecond
cfg.MinPeerExtensions.SetBit(pp.ExtensionBitFast, true)
cfg.Logger = log.Default.WithContextText(t.Name())
cfg.Logger = log.Default.WithNames(t.Name())
// 2 would suffice for the greeting test, but 5 is needed for a few other tests. This should be
// something slightly higher than the usual chunk size, so it gets tickled in some tests.
cfg.MaxAllocPeerRequestDataPerConn = 5
Expand Down

0 comments on commit 2396e6c

Please sign in to comment.