diff --git a/src/log/log.go b/src/log/log.go index 0ef05d8f94..17646a12fa 100644 --- a/src/log/log.go +++ b/src/log/log.go @@ -60,6 +60,13 @@ func New(out io.Writer, prefix string, flag int) *Logger { return &Logger{out: out, prefix: prefix, flag: flag} } +// SetOutput sets the output destination for the logger. +func (l *Logger) SetOutput(w io.Writer) { + l.mu.Lock() + defer l.mu.Unlock() + l.out = w +} + var std = New(os.Stderr, "", LstdFlags) // Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding.