handlers

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDailyTimeLayout = "2006-01-02"

Variables

This section is empty.

Functions

This section is empty.

Types

type RotatingFileHandler added in v0.2.0

type RotatingFileHandler struct {
	*logfrog.BaseLogHandler
	// contains filtered or unexported fields
}

func NewDailyRotatingFileHandler added in v0.2.0

func NewDailyRotatingFileHandler(basepath, logname string) (*RotatingFileHandler, error)

Creates a new RotatingFileHandler, that rotates daily, keeps at maximum 7 rotated files, compresses rotated logs with an level of gzip.DefaultCompression.

The current logfile is named

logname + ".log"

and rotated logs will be named with the date, i.e.:

logname + "_2006-01-02.log"

func NewRotatingFileHandler added in v0.2.0

func NewRotatingFileHandler(
	basepath, lognameFormat, oldLognameFormat string, rotateInterval RotationInterval,
) (*RotatingFileHandler, error)

Creates an new RotatingFileHandler with the given attributes. Compresses per default with a level of gzip.DefaultCompression.

The both format argumens (lognameFormat and oldLognameFormat) will be put through time.Format, so the same rules apply. I.e. the string "2006" will be replaced with the current year.

func (*RotatingFileHandler) DisableCompression added in v0.2.0

func (r *RotatingFileHandler) DisableCompression() *RotatingFileHandler

Disables compression of rotated logs

func (*RotatingFileHandler) EnableCompression added in v0.2.0

func (r *RotatingFileHandler) EnableCompression(level int) *RotatingFileHandler

Enables compression of rotated logs with the specified compression level

func (*RotatingFileHandler) GetNextRotation added in v0.2.0

func (r *RotatingFileHandler) GetNextRotation() time.Time

Returns the timestamp of the next rotation

func (*RotatingFileHandler) GetRotationInterval added in v0.2.0

func (r *RotatingFileHandler) GetRotationInterval() RotationInterval

Returns the interval in which the log is rotated

func (*RotatingFileHandler) GetUntilNextRotation added in v0.2.0

func (r *RotatingFileHandler) GetUntilNextRotation() time.Duration

Returns the duration until the next rotation

func (*RotatingFileHandler) OnClose added in v0.2.0

func (r *RotatingFileHandler) OnClose() error

func (*RotatingFileHandler) SetLognameFormat added in v0.2.0

func (r *RotatingFileHandler) SetLognameFormat(lognameFormat string) *RotatingFileHandler

Sets the format of the filename for the current rotation

func (*RotatingFileHandler) SetOldLognameFormat added in v0.2.0

func (r *RotatingFileHandler) SetOldLognameFormat(oldLognameFormat string) *RotatingFileHandler

Sets the format of the filename of rotated logfiles

func (*RotatingFileHandler) Write added in v0.2.0

func (r *RotatingFileHandler) Write(buf []byte) error

type RotationInterval added in v0.2.0

type RotationInterval int
const (
	RotateMinutely RotationInterval = iota
	RotateHourly
	RotateDaily
	RotateWeekly
)

func (RotationInterval) GetNextTimeFrame added in v0.2.0

func (r RotationInterval) GetNextTimeFrame() time.Time

Returns the next timeframe for an interval

type StreamHandler

type StreamHandler struct {
	*logfrog.BaseLogHandler
	// contains filtered or unexported fields
}

func NewStreamHandler

func NewStreamHandler(w io.Writer) *StreamHandler

func NewStreamHandlerFile

func NewStreamHandlerFile(filepath string) (*StreamHandler, error)

func NewStreamHandlerWithCloser

func NewStreamHandlerWithCloser(w io.Writer, c io.Closer) *StreamHandler

func (*StreamHandler) OnClose

func (s *StreamHandler) OnClose() error

func (*StreamHandler) Write

func (s *StreamHandler) Write(value []byte) error

Jump to

Keyboard shortcuts

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