hooks

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileRotationLogHook

type FileRotationLogHook struct {
	// contains filtered or unexported fields
}

FileRotationLogHook stores the configuration of the hook

func NewFileRotationLogHook

func NewFileRotationLogHook(fileName string, opts ...Option) *FileRotationLogHook

NewFileRotationLogHook creates a new FileRotationLogHook*/

func (*FileRotationLogHook) Fire

func (hook *FileRotationLogHook) Fire(entry *logrus.Entry) error

Fire is called when a log event is fired.

func (*FileRotationLogHook) Levels

func (hook *FileRotationLogHook) Levels() []logrus.Level

Levels returns the available logging levels

type FileRotationOption

type FileRotationOption struct {
	FileName   string
	MaxSize    int
	MaxAge     int
	MaxBackups int
	LocalTime  bool
	Compress   bool
}

FileRotationOption provides all parameters for file rotation

type Option

type Option func(*FileRotationOption)

func EnableCompression

func EnableCompression() Option

EnableCompression is to enable old log file gzip compression. Defaults to false.

func EnableLocalTime

func EnableLocalTime() Option

EnableLocalTime is to determine if the time used for formatting the timestamps in backup files is the computer's local time. The default is to use UTC time.

func WithMaxAge

func WithMaxAge(maxAge int) Option

WithMaxAge provides way to adjust max age (in days). The default is not to remove old log files based on age.

func WithMaxBackups

func WithMaxBackups(MaxBackups int) Option

WithMaxBackups provides way to adjust max number of backups. Defaults to retain all old log files though MaxAge may still cause them to get deleted.

func WithMaxSize

func WithMaxSize(maxSize int) Option

WithMaxSize provides way to adjust maxSize (in MBs). Defaults to 100 MBs.

Jump to

Keyboard shortcuts

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