rotate

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2015 License: BSD-3-Clause Imports: 8 Imported by: 0

README

rotate

go get [-u] stathat.com/c/rotate

http://godoc.org/stathat.com/c/rotate

Documentation

Overview

Package rotate implements a Writer that will write to files in a directory and rotate them when they reach a specific size. It will also only keep a fixed number of files. It can be used anywhere an io.Writer is used, for example in log.SetOutput().

Index

Constants

This section is empty.

Variables

View Source
var FilePerm = os.FileMode(0666)

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

View Source
var RootPerm = os.FileMode(0755)

RootPerm defines the permissions that Writer will use if it needs to create the root directory.

Functions

This section is empty.

Types

type Writer

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

Writer implements the io.Writer interface and writes to the "current" file in the root directory. When current's size exceeds max, it is renamed and a new file is created.

func New

func New(root, prefix string) (*Writer, error)

New creates a new Writer. The files will be created in the root directory. root will be created if necessary. The filenames will start with prefix.

func (*Writer) Close

func (r *Writer) Close() error

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

func (*Writer) SetKeep

func (r *Writer) SetKeep(n int)

SetKeep sets the number of archived files to keep.

func (*Writer) SetMax

func (r *Writer) SetMax(size int)

SetMax sets the maximum size for a file in bytes.

func (*Writer) Write

func (r *Writer) 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