mirror of
https://github.com/golang/go
synced 2024-11-23 08:10:03 -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:
parent
7980779374
commit
56ba3fb765
@ -60,6 +60,13 @@ func New(out io.Writer, prefix string, flag int) *Logger {
|
|||||||
return &Logger{out: out, prefix: prefix, flag: flag}
|
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)
|
var std = New(os.Stderr, "", LstdFlags)
|
||||||
|
|
||||||
// Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding.
|
// Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding.
|
||||||
|
Loading…
Reference in New Issue
Block a user