Commit 56ba3fb7 authored by Andrew Gerrand's avatar Andrew Gerrand

log: add SetOutput method on Logger

Fixes #9629

Change-Id: I66091003b97742ca6d857fe51d609833ab727216
Reviewed-on: https://go-review.googlesource.com/3023Reviewed-by: 's avatarRob Pike <r@golang.org>
parent 79807793
...@@ -60,6 +60,13 @@ func New(out io.Writer, prefix string, flag int) *Logger { ...@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment