aboutsummaryrefslogtreecommitdiff
path: root/src/log
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2015-01-19 14:54:53 +1100
committerAndrew Gerrand <adg@golang.org>2015-01-30 16:00:10 +0000
commit56ba3fb765bbdc0d32b8e3a75e8fcdd23507d447 (patch)
tree4001e7bf9cdb1df22122adbe1c24fb4e47a8dc5f /src/log
parent79807793748cd845685bb2a81ed0fdf2559f1684 (diff)
downloadgo-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.go7
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.