Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rotator ¶
type Rotator struct {
// contains filtered or unexported fields
}
Rotator represents a struct responsible for writing into a log file while rotating the file when it reached maxSize.
func New ¶
func New(path, filename string, maxSize uint64, perms fs.FileMode, filesToKeep uint8, useMutex bool) (*Rotator, error)
New returns a new rotator prepared to be written to. The rotator is NOT thread-safe by default, since most logging libraries already take care of that.
path: the path where log files should be written to, e.g. "/var/logs/myapp" or `C:\Logs`
filename: the name the log files are supposed to have, e.g. 'test.log'
maxSize: the maximum size in bytes a created log file may reach before it is rotated, e.g. 10 << 20 for 10MB
perms: the file permissions in octal notation, e.g. 0744 (not relevant for windows)
filesToKeep: the number of rotated files to keep. The currently written file is not counted towards this limit