diff --git a/config.go b/config.go index 625cb5c61..099d1b34c 100644 --- a/config.go +++ b/config.go @@ -162,8 +162,8 @@ func (cfg Config) Build(opts ...Option) (*Logger, error) { } log := New( - zapcore.NewCore(enc, zapcore.Lock(sink), cfg.Level), - cfg.buildOptions(zapcore.Lock(errSink))..., + zapcore.NewCore(enc, sink, cfg.Level), + cfg.buildOptions(errSink)..., ) if len(opts) > 0 { log = log.WithOptions(opts...) diff --git a/options.go b/options.go index 43c5ae383..c80146eec 100644 --- a/options.go +++ b/options.go @@ -59,8 +59,10 @@ func Fields(fs ...zapcore.Field) Option { } // ErrorOutput sets the destination for errors generated by the logger. The -// supplied WriteSyncer is automatically wrapped with a mutex, so it need not be -// safe for concurrent use. +// supplied WriteSyncer must be safe for concurrent use. +// +// The Open and zapcore.Lock functions are the simplest ways to make files safe +// for concurrent use. func ErrorOutput(w zapcore.WriteSyncer) Option { return optionFunc(func(log *Logger) { log.errorOutput = w diff --git a/writer.go b/writer.go index 0ecacb439..a042726b5 100644 --- a/writer.go +++ b/writer.go @@ -75,11 +75,11 @@ func open(paths []string) ([]zapcore.WriteSyncer, func(), error) { return writers, close, errs.AsError() } -// CombineWriteSyncers combines the passed set of WriteSyncer objects into a +// CombineWriteSyncers combines the passed set of WriteSyncers into a single // locked WriteSyncer. func CombineWriteSyncers(writers ...zapcore.WriteSyncer) zapcore.WriteSyncer { if len(writers) == 0 { return zapcore.AddSync(ioutil.Discard) } - return zapcore.NewMultiWriteSyncer(writers...) + return zapcore.Lock(zapcore.NewMultiWriteSyncer(writers...)) }