rotate

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MB  = 1024 * 1024
	Day = 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File is a file which supports rotating automatically. It has max size and file will rotate if size exceeds max size. It has max age and max backups, so rotated files will be cleaned which is beneficial to space.

func New

func New(path string, opts ...Option) (*File, error)

New returns a new rotate file.

func (*File) Close

func (f *File) Close() error

Close closes file and returns an error if failed.

func (*File) Sync

func (f *File) Sync() error

Sync syncs data to the underlying io device.

func (*File) Write

func (f *File) Write(p []byte) (n int, err error)

Write writes len(p) bytes from p to the underlying data stream.

type Option

type Option func(c *config)

Option sets some fields to config.

func WithMaxAge

func WithMaxAge(age time.Duration) Option

WithMaxAge sets max age to config.

func WithMaxBackups

func WithMaxBackups(backups uint32) Option

WithMaxBackups sets max backups to config.

func WithMaxSize

func WithMaxSize(size uint64) Option

WithMaxSize sets max size to config.

Jump to

Keyboard shortcuts

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