This repository has been archived on 2024-07-20. You can view files and clone it, but cannot push or open issues or pull requests.
logger/writer.go

23 lines
418 B
Go
Raw Normal View History

2022-06-30 10:07:29 +00:00
package logger
import (
"bytes"
"io"
)
// writer combines a buffer and a writer,
// adding a flush function to flush the buffer
// to the underlying writer. This is used
// to avoid file I/O, making the logger faster.
type writer struct {
*bytes.Buffer
w io.Writer
}
// Flush writes the buffer contents to the
// underlying writer
func (w writer) Flush() error {
_, err := io.Copy(w.w, w.Buffer)
return err
}