MCPcopy
hub / github.com/uber-go/zap / Open

Function Open

writer.go:50–58  ·  view source on GitHub ↗

Open is a high-level wrapper that takes a variadic number of URLs, opens or creates each of the specified resources, and combines them into a locked WriteSyncer. It also returns any error encountered and a function to close any opened files. Passing no URLs returns a no-op WriteSyncer. Zap handles

(paths ...string)

Source from the content-addressed store, hash-verified

48// os.Stdout and os.Stderr. When specified without a scheme, relative file
49// paths also work.
50func Open(paths ...string) (zapcore.WriteSyncer, func(), error) {
51 writers, closeAll, err := open(paths)
52 if err != nil {
53 return nil, nil, err
54 }
55
56 writer := CombineWriteSyncers(writers...)
57 return writer, closeAll, nil
58}
59
60func open(paths []string) ([]zapcore.WriteSyncer, func(), error) {
61 writers := make([]zapcore.WriteSyncer, 0, len(paths))

Callers 9

TestRegisterSinkFunction · 0.85
TestOpenNoPathsFunction · 0.85
TestOpenFunction · 0.85
TestOpenPathsNotFoundFunction · 0.85
TestOpenRelativePathFunction · 0.85
TestOpenFailsFunction · 0.85
TestOpenOtherErrorsFunction · 0.85
openSinksMethod · 0.85

Calls 2

openFunction · 0.85
CombineWriteSyncersFunction · 0.85

Tested by 8

TestRegisterSinkFunction · 0.68
TestOpenNoPathsFunction · 0.68
TestOpenFunction · 0.68
TestOpenPathsNotFoundFunction · 0.68
TestOpenRelativePathFunction · 0.68
TestOpenFailsFunction · 0.68
TestOpenOtherErrorsFunction · 0.68