Documentation ¶
Index ¶
Constants ¶
const MaxBackupsLimit = 1024
MaxBackupsLimit is the upper bound on the number of backup files. Any values greater will result in an error.
Variables ¶
This section is empty.
Functions ¶
func SafeFileRotate ¶
SafeFileRotate safely rotates an existing file under path and replaces it with the tempfile
Types ¶
type FileInfo ¶
type FileInfo interface { os.FileInfo UID() (int, error) // UID of the file owner. Returns an error on non-POSIX file systems. GID() (int, error) // GID of the file owner. Returns an error on non-POSIX file systems. }
A FileInfo describes a file and is returned by Stat and Lstat.
type Rotator ¶
type Rotator struct {
// contains filtered or unexported fields
}
Rotator is a io.WriteCloser that automatically rotates the file it is writing to when it reaches a maximum size. It also purges the oldest rotated files when the maximum number of backups is reached.
func NewFileRotator ¶
func NewFileRotator(filename string, options ...RotatorOption) (*Rotator, error)
NewFileRotator returns a new Rotator.
type RotatorOption ¶
type RotatorOption func(r *Rotator)
RotatorOption is a configuration option for Rotator.
func MaxBackups ¶
func MaxBackups(n uint) RotatorOption
MaxBackups configures the maximum number of backup files to save (not counting the active file). The upper limit is 1024 on this value is. The default is 7.
func MaxSizeBytes ¶
func MaxSizeBytes(n uint) RotatorOption
MaxSizeBytes configures the maximum number of bytes that a file should contain before being rotated. The default is 10 MiB.
func Permissions ¶
func Permissions(m os.FileMode) RotatorOption
Permissions configures the file permissions to use for the file that the Rotator creates. The default is 0600.