mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
lib/logger: Clean up LOGGER_DISCARD handing to unbreak tests
When using newLogger() with an io.Writer, that writer should in fact be used...
This commit is contained in:
parent
d4f0544d9e
commit
93ae9a1c2e
@ -70,21 +70,20 @@ type logger struct {
|
||||
var DefaultLogger = New()
|
||||
|
||||
func New() Logger {
|
||||
if os.Getenv("LOGGER_DISCARD") != "" {
|
||||
// Hack to completely disable logging, for example when running
|
||||
// benchmarks.
|
||||
return newLogger(ioutil.Discard)
|
||||
}
|
||||
return newLogger(controlStripper{os.Stdout})
|
||||
}
|
||||
|
||||
func newLogger(w io.Writer) Logger {
|
||||
res := &logger{
|
||||
return &logger{
|
||||
logger: log.New(w, "", DefaultFlags),
|
||||
facilities: make(map[string]string),
|
||||
debug: make(map[string]struct{}),
|
||||
}
|
||||
if os.Getenv("LOGGER_DISCARD") != "" {
|
||||
// Hack to completely disable logging, for example when running benchmarks.
|
||||
res.logger = log.New(ioutil.Discard, "", 0)
|
||||
return res
|
||||
}
|
||||
res.logger = log.New(w, "", DefaultFlags)
|
||||
return res
|
||||
}
|
||||
|
||||
// AddHandler registers a new MessageHandler to receive messages with the
|
||||
|
Loading…
Reference in New Issue
Block a user