anacrolix / dht

dht is used by anacrolix/torrent, and is intended for use as a library in other projects both torrent related and otherwise
Mozilla Public License 2.0
313 stars 66 forks source link

[exts:getput] Specify logger to avoid unnecessary noise #63

Closed afjoseph closed 2 years ago

afjoseph commented 2 years ago

Heyo! I'm getting a bit too many debug log statements in my project. This PR amends this noise by specifying the logger for this specific instance.

I can disable the logging using something like this:

type EmptyLogger struct{}

func (l EmptyLogger) Printf(f string, v ...interface{}) {}

// Later
getput.MyLogger = EmptyLogger{}

Cheers!

anacrolix commented 2 years ago

https://github.com/anacrolix/dht/tree/getput-context-logging is probably a bit more idiomatic for this codebase. Does it work for you? Try GO_LOG=*=debug to restore the previous logging behaviour. Note that the loggers have no context from cmd/dht, so you'll only get the file and line context in the log event here.

afjoseph commented 2 years ago

Works perfectly and seriously thanks for the extra work here. Closing...