filerotator

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2025 License: MIT Imports: 10 Imported by: 0

README

filerotator

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Local = clockFn(func() time.Time { return time.Now() })
View Source
var UTC = clockFn(func() time.Time { return time.Now().UTC() })

Functions

func CreateFile

func CreateFile(filename string) (*os.File, error)

Types

type Clock

type Clock interface {
	Now() time.Time
}

type FileRotator

type FileRotator struct {
	// contains filtered or unexported fields
}

func New

func New(logFilePath string, opts ...Option) (*FileRotator, error)

func (*FileRotator) Close

func (rotator *FileRotator) Close() error

func (*FileRotator) Rotate

func (rotator *FileRotator) Rotate(filename string) error

func (*FileRotator) Write

func (rotator *FileRotator) Write(p []byte) (n int, err error)

type Option

type Option func(*FileRotator)

func WithClock

func WithClock(clock Clock) Option

func WithMaxAge

func WithMaxAge(maxAge time.Duration) Option

func WithMaxBackup

func WithMaxBackup(maxBackup uint) Option

func WithRotateType

func WithRotateType(rotateType RotateType) Option

func WithRotationSize

func WithRotationSize(rotationSize int64) Option

func WithRotationTime

func WithRotationTime(rotationTime time.Duration) Option
func WithSymlink(symlink string) Option

type RotateType

type RotateType uint8
const (
	RotateTypeTime RotateType = iota
	RotateTypeSize
	RotateTypeBoth
)

func ParseRotationType

func ParseRotationType(s string) RotateType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL