1
0
mirror of https://github.com/golang/go synced 2024-11-23 04:50:06 -07:00

log: add SetOutput method on Logger

Fixes #9629

Change-Id: I66091003b97742ca6d857fe51d609833ab727216
Reviewed-on: https://go-review.googlesource.com/3023
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Andrew Gerrand 2015-01-19 14:54:53 +11:00
parent 7980779374
commit 56ba3fb765

View File

@ -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.