writer

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompressSuffix = ".gz"
)

Variables

This section is empty.

Functions

func New

func New(filePath string, opt ...Option) (*rollWriter, error)

New creates a new rollWriter.

Types

type Option

type Option func(*Options)

Option modifies the Options.

func WithCompress

func WithCompress(b bool) Option

WithCompress returns an Option which sets whether log files should be compressed.

func WithMaxAge

func WithMaxAge(n int) Option

WithMaxAge returns an Option which sets the max expire time(Day) of log files.

func WithMaxBackups

func WithMaxBackups(n int) Option

WithMaxBackups returns an Option which sets the max number of backup log files.

func WithMaxSize

func WithMaxSize(n int) Option

WithMaxSize returns an Option which sets the max size(MB) of log files.

func WithRotationTime

func WithRotationTime(s string) Option

WithRotationTime returns an Option which sets the time format(%Y%m%d) to roll logs.

type Options

type Options struct {
	// MaxSize is max size by byte of the log file.
	MaxSize int64

	// MaxBackups is the max number of log files.
	MaxBackups int

	// MaxAge is the max expire time by day of log files.
	MaxAge int

	// whether the log file should be compressed.
	Compress bool

	// TimeFormat is the time format to split log file by time.
	TimeFormat string
}

Options is the rollWriter call options.

Jump to

Keyboard shortcuts

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