Skip to content

Commit d98aa37

Browse files
author
Aaron Schlesinger
committed
feat(log.go): add a SetDebug func to loggers
so they can dynamically turn on and off debug logs
1 parent 5fd9351 commit d98aa37

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

log/log.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ func NewLogger(stdout, stderr io.Writer, debug bool) *Logger {
5353
// DefaultLogger is the default logging implementation. It's used in all top level funcs inside the log package, and represents the equivalent of NewLogger(os.Stdout, os.Stderr)
5454
var DefaultLogger = &Logger{stdout: os.Stdout, stderr: os.Stderr, debug: false}
5555

56-
func init() {
57-
DefaultLogger = &Logger{stdout: Stdout, stderr: Stderr, debug: IsDebugging}
56+
// SetDebug sets the internal debugging field on or off. This func is not concurrency safe
57+
func (l *Logger) SetDebug(debug bool) {
58+
l.debug = debug
5859
}
5960

6061
// Msg passes through the formatter, but otherwise prints exactly as-is.

0 commit comments

Comments
 (0)