logs

package
v0.0.0-...-4f62844 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MulanPSL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(path, name, level string)

Types

type LfsHook

type LfsHook struct {
	Field     string
	Skip      int
	Formatter func(file, function string, line int) string
	// contains filtered or unexported fields
}

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

func NewHook

func NewHook(output interface{}, formatter logrus.Formatter) *LfsHook

NewHook returns new LFS hook. Output can be a string, io.Writer, WriterMap or PathMap. If using io.Writer or WriterMap, user is responsible for closing the used io.Writer.

func (*LfsHook) Fire

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

Fire writes the log file to defined path or using the defined writer. User who run this function needs write permissions to the file or directory if the file does not yet exist.

func (*LfsHook) Levels

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

Levels returns configured log levels.

func (*LfsHook) SetDefaultPath

func (hook *LfsHook) SetDefaultPath(defaultPath string)

SetDefaultPath sets default path for levels that don't have any defined output path.

func (*LfsHook) SetDefaultWriter

func (hook *LfsHook) SetDefaultWriter(defaultWriter io.Writer)

SetDefaultWriter sets default writer for levels that don't have any defined writer.

func (*LfsHook) SetFormatter

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

SetFormatter sets the format that will be used by hook. If using text formatter, this method will disable color output to make the log file more readable.

type PathMap

type PathMap map[logrus.Level]string

PathMap is map for mapping a log level to a file's path. Multiple levels may share a file, but multiple files may not be used for one level.

type WriterMap

type WriterMap map[logrus.Level]io.Writer

WriterMap is map for mapping a log level to an io.Writer. Multiple levels may share a writer, but multiple writers may not be used for one level.

Jump to

Keyboard shortcuts

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