From 2db0c5c7416436f99852592d2f258ca93da96712 Mon Sep 17 00:00:00 2001 From: Andrew Poydence Date: Thu, 25 Oct 2018 16:20:09 -0600 Subject: [PATCH] log: add Writer method to Logger Writer method returns the underlying io.Writer used by the given Logger object. Fixes #28327 --- src/log/log.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/log/log.go b/src/log/log.go index 2b7c57fdfe5ff..527f853438f08 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()