Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove WriteSyncer's automatic lock #369

Merged
merged 3 commits into from
Mar 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ 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 = zapcore.Lock(w)
log.errorOutput = w
})
}

Expand Down
4 changes: 2 additions & 2 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func open(paths []string) ([]zapcore.WriteSyncer, func(), error) {
return writers, close, errs.AsError()
}

// CombineWriteSyncers combines the passed set of WriteSyncer objects into a
// locked WriteSyncer.
// CombineWriteSyncers combines multiple WriteSyncers into a single, locked
// WriteSyncer.
func CombineWriteSyncers(writers ...zapcore.WriteSyncer) zapcore.WriteSyncer {
if len(writers) == 0 {
return zapcore.AddSync(ioutil.Discard)
Expand Down
2 changes: 1 addition & 1 deletion zapcore/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewCore(enc Encoder, ws WriteSyncer, enab LevelEnabler) Core {
return &ioCore{
LevelEnabler: enab,
enc: enc,
out: Lock(ws),
out: ws,
}
}

Expand Down