rotate

package
v1.16.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilePerm   = os.FileMode(0644)
	DateFormat = "2006-01-02"
)

FilePerm defines the permissions that Writer will use for all the files it creates.

Variables

This section is empty.

Functions

func NewFileWriter

func NewFileWriter(filename string, interval time.Duration, maxSizeInBytes int64, maxArchives int) (io.WriteCloser, error)

NewFileWriter creates a new file writer.

Types

type FileWriter

type FileWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FileWriter implements the io.Writer interface and writes to the filename specified. Will rotate at the specified interval and/or when the current file size exceeds maxSizeInBytes At rotation time, current file is renamed and a new file is created. If the number of archives exceeds maxArchives, older files are deleted.

func (*FileWriter) Close

func (w *FileWriter) Close() (err error)

Close closes the current file. Writer is unusable after this is called.

func (*FileWriter) Write

func (w *FileWriter) Write(p []byte) (n int, err error)

Write writes p to the current file, then checks to see if rotation is necessary.

Jump to

Keyboard shortcuts

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