From 719c313b23656a47545e199073db583771a59278 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Fri, 2 Jun 2017 07:04:06 +0000 Subject: [PATCH] cmd/syncthing, lib/logger: Set debug flags on SetDebug for tests GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4187 --- cmd/syncthing/main.go | 2 +- lib/logger/logger.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 058df843..724c259b 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -269,7 +269,7 @@ func defaultRuntimeOptions() RuntimeOptions { } if os.Getenv("STTRACE") != "" { - options.logFlags = log.Ltime | log.Ldate | log.Lmicroseconds | log.Lshortfile + options.logFlags = logger.DebugFlags } if runtime.GOOS != "windows" { diff --git a/lib/logger/logger.go b/lib/logger/logger.go index 5d927fe4..d09b8662 100644 --- a/lib/logger/logger.go +++ b/lib/logger/logger.go @@ -28,6 +28,8 @@ const ( NumLevels ) +const DebugFlags = log.Ltime | log.Ldate | log.Lmicroseconds | log.Lshortfile + // A MessageHandler is called with the log level and message text. type MessageHandler func(l LogLevel, msg string) @@ -215,6 +217,7 @@ func (l *logger) SetDebug(facility string, enabled bool) { l.mut.Lock() l.debug[facility] = enabled l.mut.Unlock() + l.SetFlags(DebugFlags) } // FacilityDebugging returns the set of facilities that have debugging