Skip to content

Commit 51104cd

Browse files
Andrew Poydencerobpike
Andrew Poydence
authored andcommitted
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: 2db0c5c GitHub-Pull-Request: #28399 Reviewed-on: https://go-review.googlesource.com/c/144757 Reviewed-by: Rob Pike <[email protected]>
1 parent 7a63403 commit 51104cd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/log/log.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ func (l *Logger) SetPrefix(prefix string) {
254254
l.prefix = prefix
255255
}
256256

257+
// Writer returns the output destination for the logger.
258+
func (l *Logger) Writer() io.Writer {
259+
l.mu.Lock()
260+
defer l.mu.Unlock()
261+
return l.out
262+
}
263+
257264
// SetOutput sets the output destination for the standard logger.
258265
func SetOutput(w io.Writer) {
259266
std.mu.Lock()

0 commit comments

Comments
 (0)