Documentation
¶
Overview ¶
Package writer contains a series of writers that can write the log entries. A File can write logs to a given file. It will collapse the object if a json object is given, and uses them as the context of the log.
Index ¶
- Variables
- func WithBufWriter(w *bufio.Writer) func(*File) error
- func WithFileLoc(location string) func(*File) error
- func WithFlushDelay(delay time.Duration) func(*File) error
- func WithLogger(logger internal.FieldLogger) func(*File) error
- func WithWriter(w writeCloseNamer) func(*File) error
- type Distribute
- type File
Constants ¶
This section is empty.
Variables ¶
var MinimumDelay = 10 * time.Millisecond
MinimumDelay is the minimum time set for flush delays.
Functions ¶
func WithBufWriter ¶
WithBufWriter sets the buffered writer.
func WithFileLoc ¶
WithFileLoc opens a new file at location, or creates one if not exists. It returns error if it could not create or have write permission to the file.
func WithFlushDelay ¶
WithFlushDelay sets the delay time between flushes.
func WithLogger ¶
func WithLogger(logger internal.FieldLogger) func(*File) error
WithLogger sets the delay time between flushes.
func WithWriter ¶
WithWriter sets the output as the given writer. It wraps it in a buffer for better performance.
Types ¶
type Distribute ¶ added in v0.1.0
Distribute is a concurrent writer.
func NewDistribute ¶ added in v0.1.0
func NewDistribute(writers ...io.Writer) *Distribute
NewDistribute returns no errors. It dismissed the writers with nil values.
type File ¶
type File struct {
sync.Mutex // guards against the buffer
// contains filtered or unexported fields
}
File writs records log entries to a file. It buffers the writes to obtain better performance. It flushes the buffer every 1 seconds. It implements io.WriteCloser interface.
func NewFile ¶
NewFile returns error if the file can not be created. It starts a goroutine that flushes the logs in intervals.
func (*File) Logger ¶ added in v0.0.3
func (f *File) Logger() internal.FieldLogger
Logger returns the logger attached to the file