From f83de79b81aaf837343796c21e4b988b62c73055 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Mon, 25 May 2020 19:57:14 +0200 Subject: [PATCH] Improve documentation wording for SyncWriter (#235) There is already a lock in place for both POSIX (Linux/Unix/Darwin) and Windows, see: https://github.com/golang/go/blob/go1.14.3/src/internal/poll/fd_windows.go#L684 https://github.com/golang/go/blob/go1.14.3/src/internal/poll/fd_unix.go#L255 --- writer.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/writer.go b/writer.go index 67605e2a..381b0f61 100644 --- a/writer.go +++ b/writer.go @@ -26,11 +26,9 @@ type syncWriter struct { } // SyncWriter wraps w so that each call to Write is synchronized with a mutex. -// This syncer can be the call to writer's Write method is not thread safe. -// Note that os.File Write operation is using write() syscall which is supposed -// to be thread-safe on POSIX systems. So there is no need to use this with -// os.File on such systems as zerolog guarantees to issue a single Write call -// per log event. +// This syncer can be used to wrap the call to writer's Write method if it is +// not thread safe. Note that you do not need this wrapper for os.File Write +// operations on POSIX and Windows systems as they are already thread-safe. func SyncWriter(w io.Writer) io.Writer { if lw, ok := w.(LevelWriter); ok { return &syncWriter{lw: lw}