rotate

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRotateMaxAge               = 7 * 24 * time.Hour
	DefaultRotateDuration             = 24 * time.Hour
	DefaultRotatePattern              = ".%Y%m%d%H%M"
	DefaultLogDir                     = "/data/log"
	DefaultLogSubDir                  = "info"
	DefaultFileMode       os.FileMode = 0755
)

Variables

View Source
var (
	DefaultFilename = filepath.Base(os.Args[0])
	DefaultLocation = Location()
)

Functions

func Location

func Location() *time.Location

func NewRotateLogger

func NewRotateLogger(rcfg *Config) (*rotatelogs.RotateLogs, error)

func NewWriter

func NewWriter(opts ...Option) (io.Writer, error)

Types

type Config

type Config struct {
	Dir      string
	Sub      string
	Filename string
	Perm     os.FileMode
	Age      time.Duration
	Duration time.Duration
	Pattern  string
	Count    uint
	Loc      *time.Location
}

func NewWriterConfig

func NewWriterConfig() *Config

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAge

func WithAge(Age time.Duration) Option

func WithCount

func WithCount(Count uint) Option

sets the number of files should be kept before it gets purged from the file system.

func WithDuration

func WithDuration(Duration time.Duration) Option

func WithFileMode

func WithFileMode(Perm os.FileMode) Option

func WithFilename

func WithFilename(fn string) Option

func WithLocation

func WithLocation(loc *time.Location) Option

func WithLogDir

func WithLogDir(dir string) Option

func WithLogSubDir

func WithLogSubDir(dir string) Option

func WithPattern

func WithPattern(Pattern string) Option

Directories

Path Synopsis
package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify.
package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify.

Jump to

Keyboard shortcuts

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