From 51104cd4d2dab6bdd8bda694c0a9a5613cec3b84 Mon Sep 17 00:00:00 2001 From: Andrew Poydence Date: Thu, 25 Oct 2018 23:14:15 +0000 Subject: [PATCH] log: add Logger.Writer method Writer method returns the underlying io.Writer used by the given Logger object. Fixes #28327 Change-Id: I6347913d8be8d3222b98967b136cf03d00f446d1 GitHub-Last-Rev: 2db0c5c7416436f99852592d2f258ca93da96712 GitHub-Pull-Request: golang/go#28399 Reviewed-on: https://go-review.googlesource.com/c/144757 Reviewed-by: Rob Pike --- src/log/log.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/log/log.go b/src/log/log.go index 2b7c57fdfe..527f853438 100644 --- a/src/log/log.go +++ b/src/log/log.go @@ -254,6 +254,13 @@ func (l *Logger) SetPrefix(prefix string) { l.prefix = prefix } +// Writer returns the output destination for the logger. +func (l *Logger) Writer() io.Writer { + l.mu.Lock() + defer l.mu.Unlock() + return l.out +} + // SetOutput sets the output destination for the standard logger. func SetOutput(w io.Writer) { std.mu.Lock()