Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFSHook ¶
func NewFSHook(path string, formatter log.Formatter, rotSched RotationScheduler, options ...func(*fsHook)) log.Hook
NewFSHook makes a logging hook that writes formatted log entries to info, warn and error log files. Each log file contains the messages with that severity or higher. If a formatter is not specified, they will be logged using a JSON formatter. If a RotationScheduler is set, the files will be cycled according to its rules.
func WithFileMode ¶
Types ¶
type DailyRotationSchedule ¶
type DailyRotationSchedule struct {
GZip bool
// contains filtered or unexported fields
}
DailyRotationSchedule rotates log files daily. Logs are only rotated when midnight passes *whilst the process is running*. E.g: if you run the process on Day 4 then stop it and start it on Day 7, no rotation will occur when the process starts.
func (*DailyRotationSchedule) ShouldGZip ¶
func (rs *DailyRotationSchedule) ShouldGZip() bool
func (*DailyRotationSchedule) ShouldRotate ¶
func (rs *DailyRotationSchedule) ShouldRotate() (bool, string)
ShouldRotate compares the current time with the rotation schedule. If the rotation should occur, returns (true, suffix) where suffix is the suffix for the rotated file. Else, returns (false, "")
type RotationScheduler ¶
type RotationScheduler interface {
// ShouldRotate returns true if the file should be rotated. The suffix to apply
// to the filename is returned as the 2nd arg.
ShouldRotate() (bool, string)
// ShouldGZip returns true if the file should be gzipped when it is rotated.
ShouldGZip() bool
}
RotationScheduler determines when files should be rotated.