hooks

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextHook

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

ContextHook represents a hook for logrus logger.

func NewContextHook

func NewContextHook(contextKey interface{}, fn func(entry *log.Entry, ctxValue interface{})) *ContextHook

NewContextHook creates a new ContextHook instance

func (*ContextHook) Fire

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

Fire implements logrus.ContextHook.Fire()

func (*ContextHook) Levels

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

Levels implements logrus.ContextHook.Levels()

type ContextHookFormatFn

type ContextHookFormatFn func(ctxValue interface{}, msg string) string

ContextHookFormatFn is the callback function for formating message

type FileHook

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

FileHook is a hook to handle writing to local log files.

func NewFileHook

func NewFileHook(filename string) *FileHook

NewFileHook returns new FileHook instance with default values.

func (*FileHook) Fire

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

Fire writes the log file to defined filename path.

func (*FileHook) Levels

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

Levels returns configured log levels.

func (*FileHook) SetFormatter

func (hook *FileHook) SetFormatter(formatter logrus.Formatter)

SetFormatter sets the format that will be used by hook.

func (*FileHook) SetMaxAge

func (hook *FileHook) SetMaxAge(maxAge time.Duration)

SetMaxAge sets the maximum duration to retain old log files based on the timestamp encoded in their filename.

func (*FileHook) SetMaxSize

func (hook *FileHook) SetMaxSize(maxSize int)

SetMaxSize sets the maximum size in megabytes of the log file before it gets rotated.

Jump to

Keyboard shortcuts

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