rotation

package
v0.0.0-...-414a959 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2017 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package rotation writes and rotates log files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

A File is a log file with associated rotation files. The rotation files are named after the base file with a numeric suffix: base.1, base.2, and so on. Calls to Write write data to the base file. When the base file reaches the given size, it is renamed to base.1 (and base.1 is renamed to base.2, and so on) and a new base file is opened for subsequent writes.

Any errors encountered while rotating files are ignored. Only errors opening and writing the base file are reported.

func Create

func Create(name string, size, n int) *File

Create creates a log writing to the named file with mode 0644 (before umask), appending to it if it already exists. It will rotate to files name.1, name.2, up to name.n. The minimum value for n is 1; lesser values will be taken as 1.

func (*File) Write

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

Write writes p to the log file f. It writes only complete lines to the underlying file. Incomplete lines are buffered in memory and written once a NL is encountered.

Jump to

Keyboard shortcuts

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