Documentation
¶
Index ¶
- Variables
- func AsStdLogger(l logrus.FieldLogger, level logrus.Level, prefix string, flag int) *log.Logger
- func AsStdLoggerWithLevel(l logrus.FieldLogger, level logrus.Level) *log.Logger
- func StandardWriter(level logrus.Level) io.Writer
- func WithReporterCaller(log *logrus.Logger, ...)
- func WithRotate(log *logrus.Logger, path string, options ...RotateOption) error
- func Writer(l logrus.FieldLogger, level logrus.Level) io.Writer
- type EmptyRotateOption
- type HookFunc
- type HookMap
- type RotateOption
- func WithFileLinkPath(link string) RotateOption
- func WithForceNewFileOnStartup(force bool) RotateOption
- func WithMaxAge(maxAge time.Duration) RotateOption
- func WithMaxCount(maxCount int) RotateOption
- func WithMuteDirectlyOutput(mute bool) RotateOption
- func WithRotateInterval(interval time.Duration) RotateOption
- func WithRotateLayout(layout string) RotateOption
- func WithRotateSize(size int64) RotateOption
- func WithRotateStrftime(layout string) RotateOption
- type RotateOptionFunc
Constants ¶
This section is empty.
Variables ¶
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
AsStdLogger returns *log.Logger from logrus.FieldLogger
func AsStdLoggerWithLevel ¶ added in v0.1.158
AsStdLoggerWithLevel is only a helper of AsStdLogger
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
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 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.