mirror of
https://github.com/octoleo/syncthing.git
synced 2025-04-02 15:51:51 +00:00
cmd/syncthing, lib/logger: Set debug flags on SetDebug for tests
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4187
This commit is contained in:
parent
3d11efc9e0
commit
719c313b23
@ -269,7 +269,7 @@ func defaultRuntimeOptions() RuntimeOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("STTRACE") != "" {
|
if os.Getenv("STTRACE") != "" {
|
||||||
options.logFlags = log.Ltime | log.Ldate | log.Lmicroseconds | log.Lshortfile
|
options.logFlags = logger.DebugFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
|
@ -28,6 +28,8 @@ const (
|
|||||||
NumLevels
|
NumLevels
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const DebugFlags = log.Ltime | log.Ldate | log.Lmicroseconds | log.Lshortfile
|
||||||
|
|
||||||
// A MessageHandler is called with the log level and message text.
|
// A MessageHandler is called with the log level and message text.
|
||||||
type MessageHandler func(l LogLevel, msg string)
|
type MessageHandler func(l LogLevel, msg string)
|
||||||
|
|
||||||
@ -215,6 +217,7 @@ func (l *logger) SetDebug(facility string, enabled bool) {
|
|||||||
l.mut.Lock()
|
l.mut.Lock()
|
||||||
l.debug[facility] = enabled
|
l.debug[facility] = enabled
|
||||||
l.mut.Unlock()
|
l.mut.Unlock()
|
||||||
|
l.SetFlags(DebugFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FacilityDebugging returns the set of facilities that have debugging
|
// FacilityDebugging returns the set of facilities that have debugging
|
||||||
|
Loading…
x
Reference in New Issue
Block a user