logfile

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (

	//KB Kilobytes
	KB = 1 << (10 * iota)
	//MB Megabytes
	MB
	//GB Gigabytes
	GB
	//TB Terabytes
	TB

	// DefaultRotationRate defines the default value for rotation refresh rate
	DefaultRotationRate = time.Millisecond * 250
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLogFile added in v1.1.2

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

BaseLogFile structure definition

func (*BaseLogFile) Close added in v1.1.2

func (b *BaseLogFile) Close() error

Close implements LogFile interface

func (*BaseLogFile) Path added in v1.1.2

func (b *BaseLogFile) Path() string

Path implements LogFile interface

func (*BaseLogFile) Rotate added in v1.1.3

func (b *BaseLogFile) Rotate() (err error)

Rotate implements LogFile interface

func (*BaseLogFile) Write added in v1.1.2

func (b *BaseLogFile) Write(p []byte) (int, error)

Write implements LogFile interface

func (*BaseLogFile) WriteString added in v1.1.3

func (b *BaseLogFile) WriteString(s string) (int, error)

WriteString implements LogFile interface

type LogFile

type LogFile interface {
	// Path returns the path of the current LogFile
	Path() string
	// Rotate ensures file rotation
	Rotate() error
	// Rotation routine
	RotRoutine()
	// Write used to write to the LogFile
	Write([]byte) (int, error)
	// Close used to close the LogFile
	Close() error
}

LogFile interface

type SizeRotateLogFile added in v1.1.2

type SizeRotateLogFile struct {
	BaseLogFile
	// contains filtered or unexported fields
}

SizeRotateLogFile structure definition A SizeRotateLogFile is a GZIP compressed file which rotates automatically

func OpenSizeRotateLogFile added in v1.1.3

func OpenSizeRotateLogFile(path string, perm os.FileMode, size int64) (*SizeRotateLogFile, error)

OpenSizeRotateLogFile opens a new log file for logging rotating according to its own size

func (*SizeRotateLogFile) RotRoutine added in v1.1.3

func (l *SizeRotateLogFile) RotRoutine()

RotRoutine implements LogFile

type TimeRotateLogFile added in v1.1.2

type TimeRotateLogFile struct {
	BaseLogFile
	// contains filtered or unexported fields
}

TimeRotateLogFile structure definition. A TimeRotateLogFile rotates at whenever rotation delay expires. The current file being used is in plain-text. Whenever the rotation happens, the file is GZIP-ed to save space on disk. A delay can be specified in order to wait before the file is compressed.

func OpenTimeRotateLogFile added in v1.1.2

func OpenTimeRotateLogFile(path string, perm os.FileMode, drot time.Duration) (l *TimeRotateLogFile, err error)

OpenTimeRotateLogFile opens a new TimeRotateLogFile drot controls the rotation delay and dgzip the time to wait before the latest file is GZIPed

func (*TimeRotateLogFile) Close added in v1.1.2

func (l *TimeRotateLogFile) Close() error

Close implements LogFile interface

func (*TimeRotateLogFile) RotRoutine added in v1.1.3

func (l *TimeRotateLogFile) RotRoutine()

RotRoutine implements LogFile

Jump to

Keyboard shortcuts

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