diff options
author | Andrew Gerrand <adg@golang.org> | 2015-01-19 14:54:53 +1100 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2015-01-30 16:00:10 +0000 |
commit | 56ba3fb765bbdc0d32b8e3a75e8fcdd23507d447 (patch) | |
tree | 4001e7bf9cdb1df22122adbe1c24fb4e47a8dc5f /src/log | |
parent | 79807793748cd845685bb2a81ed0fdf2559f1684 (diff) | |
download | go-56ba3fb765bbdc0d32b8e3a75e8fcdd23507d447.tar.gz go-56ba3fb765bbdc0d32b8e3a75e8fcdd23507d447.zip |
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>
Diffstat (limited to 'src/log')
-rw-r--r-- | src/log/log.go | 7 |
1 files changed, 7 insertions, 0 deletions
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. |