rotation

package
v1.71.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MPL-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package rotation provides file rotation when files hit a given size.

Index

Constants

View Source
const (
	DefaultMaxSize    = 10 * 1024 * 1024
	DefaultMaxBackups = 1
)

Constants for defaults.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the default path that will be used. This will use cmdline.AppIdentifier (if set) to better isolate the log location.

func MaxBackups

func MaxBackups(maxBackups int) func(*Rotator) error

MaxBackups sets the maximum number of old log files to retain. Defaults to DefaultMaxBackups.

func MaxSize

func MaxSize(maxSize int64) func(*Rotator) error

MaxSize sets the maximum size of the log file before it gets rotated. Defaults to DefaultMaxSize.

func Path

func Path(path string) func(*Rotator) error

Path specifies the file to write logs to. Backup log files will be retained in the same directory. Defaults to the value of DefaultPath().

func WithMask added in v1.40.0

func WithMask(mask os.FileMode) func(*Rotator) error

WithMask sets the mask when creating files, which have the unmasked mode of 0644, and directories, which have the unmasked mode of 0755. Defaults to 0777.

Types

type Rotator

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

Rotator holds the rotator data.

func New

func New(options ...func(*Rotator) error) (*Rotator, error)

New creates a new Rotator with the specified options.

func (*Rotator) Close

func (r *Rotator) Close() error

Close implements io.Closer.

func (*Rotator) Write

func (r *Rotator) Write(b []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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