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

Method Write

zapio/writer.go:75–87  ·  view source on GitHub ↗

Write writes the provided bytes to the underlying logger at the configured log level and returns the length of the bytes. Write will split the input on newlines and post each line as a new log entry to the logger.

(bs []byte)

Source from the content-addressed store, hash-verified

73// Write will split the input on newlines and post each line as a new log entry
74// to the logger.
75func (w *Writer) Write(bs []byte) (n int, err error) {
76 // Skip all checks if the level isn't enabled.
77 if !w.Log.Core().Enabled(w.Level) {
78 return len(bs), nil
79 }
80
81 n = len(bs)
82 for len(bs) > 0 {
83 bs = w.writeLine(bs)
84 }
85
86 return n, nil
87}
88
89// writeLine writes a single line from the input, returning the remaining,
90// unconsumed bytes.

Callers 1

BenchmarkWriterFunction · 0.95

Calls 3

writeLineMethod · 0.95
CoreMethod · 0.80
EnabledMethod · 0.65

Tested by 1

BenchmarkWriterFunction · 0.76