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)
| 73 | // Write will split the input on newlines and post each line as a new log entry |
| 74 | // to the logger. |
| 75 | func (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. |