rotate

package module
v0.0.0-...-90ecb98 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 14 Imported by: 0

README

rotate

rotate is a file rolling package for Go

The package is similar to lumberjack but reduces the use of channel feature

How to use

writer, _ := rotate.NewRotateWriter(
    "/var/log/myapp/foo.log",
    rotate.WithMaxSize(500),   // megabytes
    rotate.WithKeepDays(30),   // days
    rotate.WithMaxBackups(100), 
)
log.SetOutput(&writer)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNameIsEmpty = errors.New("error: file name is empty")
	ErrLogFileClosed   = errors.New("error: log file closed")
	ErrDataOversize    = errors.New("error: model size exceeds maximum")
)

Functions

This section is empty.

Types

type RotateOption

type RotateOption func(*rotateOption)

func WithDelimiter

func WithDelimiter(s string) RotateOption

WithDelimiter

func WithGzip

func WithGzip(gzip bool) RotateOption

WithGzip

func WithLocalTime

func WithLocalTime(local bool) RotateOption

WithLocalTime

func WithMaxBackups

func WithMaxBackups(max int64) RotateOption

WithMaxBackups

func WithMaxDays

func WithMaxDays(days int64) RotateOption

WithMaxDays

func WithMaxSize

func WithMaxSize(max int64) RotateOption

WithMaxSize

func WithTimeFormat

func WithTimeFormat(format string) RotateOption

WithTimeFormat

type RotateWriter

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

func NewRotateWriter

func NewRotateWriter(filename string, options ...RotateOption) (*RotateWriter, error)

NewRotateWriter rotate

func (*RotateWriter) Close

func (r *RotateWriter) Close() (err error)

Close

func (*RotateWriter) Write

func (r *RotateWriter) Write(data []byte) (int, error)

Write

Jump to

Keyboard shortcuts

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