rw

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: BSD-2-Clause Imports: 5 Imported by: 2

Documentation

Overview

RotateWriter interfaces to io.Writer to automaticly rotate the log file based on max size and/or time

Index

Constants

This section is empty.

Variables

View Source
var (
	Megabyte int64 = 1024 * 1024 // Variable to use along with MaxSize to use megabytes.
	Kilobyte int64 = 1024        // Variable to use along with MaxSize to use kilobytes.
)

Functions

This section is empty.

Types

type RotateWriter

type RotateWriter struct {
	Dir        string        // the directory to put log files.
	Filename   string        // should be set to the actual filename and extension.
	ExpireTime time.Duration // how often the log should rotate.
	OldTime    time.Duration // what age should logs be considered old.
	MaxSize    int64         // max size a log file is allowed to be in bytes.
	// contains filtered or unexported fields
}

The structure for RotateWriter, which should interface io.Writer

func (*RotateWriter) Janitor

func (w *RotateWriter) Janitor() error

Janitor - cleans up old log files in via directory.

func (*RotateWriter) Resume

func (w *RotateWriter) Resume() error

Create a new log file does not exists, opens if log file does exists.

func (*RotateWriter) Rotate

func (w *RotateWriter) Rotate() error

Perform the actual act of rotating and reopening file.

func (*RotateWriter) Write

func (w *RotateWriter) Write(output []byte) (int, error)

Write satisfies the io.Writer interface.

Jump to

Keyboard shortcuts

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