logrus

package
v1.0.157 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShortCallerPrettyfier = func(f *runtime.Frame) (function string, file string) {
	funcname := path.Base(f.Function)
	filename := path.Base(f.File)
	return fmt.Sprintf("%s()", funcname), fmt.Sprintf("%s:%d", filename, f.Line)
}

ShortCallerPrettyfier modify the content of the function and file keys in the data when ReportCaller is activated. INFO[0000] main.go:23 main() hello world

Functions

func AsStdLogger added in v0.1.158

func AsStdLogger(l logrus.FieldLogger, level logrus.Level, prefix string, flag int) *log.Logger

AsStdLogger returns *log.Logger from logrus.FieldLogger

func AsStdLoggerWithLevel added in v0.1.158

func AsStdLoggerWithLevel(l logrus.FieldLogger, level logrus.Level) *log.Logger

AsStdLoggerWithLevel is only a helper of AsStdLogger

func StandardWriter added in v0.1.158

func StandardWriter(level logrus.Level) io.Writer

func WithReporterCaller added in v0.0.54

func WithReporterCaller(log *logrus.Logger, callerPrettyfier func(*runtime.Frame) (function string, file string))

WithReporterCaller enhances logrus log to log caller info callerPrettyfier is defined in logrus.TextFormatter and logrus.JSONFormatter. callerPrettyfier affects only if formatter is logrus.TextFormatter and logrus.JSONFormatter. if callerPrettyfier not set, ShortCallerPrettyfier is set

func WithRotate added in v0.0.138

func WithRotate(log *logrus.Logger, path string, options ...RotateOption) error

WithRotate enhances logrus log to be written to local filesystem, with file rotation path sets log's base path prefix

func Writer added in v0.1.158

func Writer(l logrus.FieldLogger, level logrus.Level) io.Writer

Types

type EmptyRotateOption added in v0.0.138

type EmptyRotateOption struct{}

EmptyRotateOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type HookFunc added in v0.0.135

type HookFunc func(entry *logrus.Entry) error

func (HookFunc) Fire added in v0.0.135

func (f HookFunc) Fire(entry *logrus.Entry) error

func (HookFunc) Levels added in v0.0.135

func (f HookFunc) Levels() []logrus.Level

type HookMap added in v0.0.135

type HookMap map[logrus.Level]func(entry *logrus.Entry) error

func (HookMap) Fire added in v0.0.135

func (hooks HookMap) Fire(entry *logrus.Entry) error

func (HookMap) Levels added in v0.0.135

func (hooks HookMap) Levels() []logrus.Level

type RotateOption added in v0.0.138

type RotateOption interface {
	// contains filtered or unexported methods
}

A RotateOption sets options.

func WithFileLinkPath added in v0.0.138

func WithFileLinkPath(link string) RotateOption

WithFileLinkPath sets the symbolic link name that gets linked to the current file name being used.

func WithForceNewFileOnStartup added in v0.0.138

func WithForceNewFileOnStartup(force bool) RotateOption

WithMaxCount force rotates files directly when start up

func WithMaxAge added in v0.0.138

func WithMaxAge(maxAge time.Duration) RotateOption

WithMaxAge sets max age of a log file before it gets purged from the file system. Remove rotated logs older than duration. The age is only checked if the file is to be rotated. take effects if only MaxAge is bigger than 0.

func WithMaxCount added in v0.0.138

func WithMaxCount(maxCount int) RotateOption

WithMaxCount rotates files are rotated MaxCount times before being removed take effects if only MaxCount is bigger than 0.

func WithMuteDirectlyOutput added in v0.0.138

func WithMuteDirectlyOutput(mute bool) RotateOption

WithForceNewFileOnStartup mutes writer of logrus.Output if level is InfoLevel、DebugLevel、TraceLevel...

func WithRotateInterval added in v0.0.138

func WithRotateInterval(interval time.Duration) RotateOption

WithRotateInterval rotates files are rotated until RotateInterval expired before being removed take effects if only RotateInterval is bigger than 0.

func WithRotateLayout added in v0.0.138

func WithRotateLayout(layout string) RotateOption

WithRotateLayout sets time layout to format rotate file.

func WithRotateSize added in v0.0.138

func WithRotateSize(size int64) RotateOption

WithRotateSize rotates files are rotated if they grow bigger then size bytes. take effects if only RotateSize is bigger than 0.

func WithRotateStrftime added in v0.0.138

func WithRotateStrftime(layout string) RotateOption

WithRotateStrftime sets time layout in strftime format to format rotate file.

type RotateOptionFunc added in v0.0.138

type RotateOptionFunc func(*rotate)

RotateOptionFunc wraps a function that modifies rotate into an implementation of the RotateOption interface.

Jump to

Keyboard shortcuts

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