]> Cypherpunks repositories - gostls13.git/commitdiff
log: add SetOutput method on Logger
authorAndrew Gerrand <adg@golang.org>
Mon, 19 Jan 2015 03:54:53 +0000 (14:54 +1100)
committerAndrew Gerrand <adg@golang.org>
Fri, 30 Jan 2015 16:00:10 +0000 (16:00 +0000)
Fixes #9629

Change-Id: I66091003b97742ca6d857fe51d609833ab727216
Reviewed-on: https://go-review.googlesource.com/3023
Reviewed-by: Rob Pike <r@golang.org>
src/log/log.go

index 0ef05d8f94bf5ec30db26941404d61c579192ba5..17646a12fa8872877e5c282ace6c1d01c981fc42 100644 (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.