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)
| 48 | // os.Stdout and os.Stderr. When specified without a scheme, relative file |
| 49 | // paths also work. |
| 50 | func 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 | |
| 60 | func open(paths []string) ([]zapcore.WriteSyncer, func(), error) { |
| 61 | writers := make([]zapcore.WriteSyncer, 0, len(paths)) |