logfile

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: GPL-3.0 Imports: 9 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) Write added in v1.1.2

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

Write implements LogFile interface

type LogFile

type LogFile interface {
	// Path returns the path of the current LogFile
	Path() string
	// Rotate ensures file rotation
	Rotate() error
	// 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 {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func OpenFile

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

OpenFile opens a new file for logging

func (*SizeRotateLogFile) Close added in v1.1.2

func (l *SizeRotateLogFile) Close() error

Close closes the LogFileSizeRotate properly

func (*SizeRotateLogFile) Flush added in v1.1.2

func (l *SizeRotateLogFile) Flush() error

Flush method

func (*SizeRotateLogFile) Path added in v1.1.2

func (l *SizeRotateLogFile) Path() string

Path returns the path of the LogFileSizeRotate

func (*SizeRotateLogFile) Rotate added in v1.1.2

func (l *SizeRotateLogFile) Rotate() error

Rotate rotates the current LogFileSizeRotate

func (*SizeRotateLogFile) SetRefreshRate added in v1.1.2

func (l *SizeRotateLogFile) SetRefreshRate(rate time.Duration)

SetRefreshRate sets the rate at which the LogFileSizeRotate should check for rotating check DefaultRotationRate for default value

func (*SizeRotateLogFile) Write added in v1.1.2

func (l *SizeRotateLogFile) Write(b []byte) (int, error)

Write writes bytes into the LogFileSizeRotate

func (*SizeRotateLogFile) WriteString added in v1.1.2

func (l *SizeRotateLogFile) WriteString(s string) (int, error)

WriteString writes a string into the LogFileSizeRotate

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, dgzip 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. Whenever the TimeRotateLogFile is closed the last file in use is GZIP compressed before Close returns

func (*TimeRotateLogFile) Rotate added in v1.1.2

func (l *TimeRotateLogFile) Rotate() (err error)

Rotate implements LogFile interface

Jump to

Keyboard shortcuts

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