log

package
v1.3.90 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 14 Imported by: 2 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(format string, args ...interface{})

func Debugln

func Debugln(args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(format string, args ...interface{})

func Errorln

func Errorln(args ...interface{})

func Eventf

func Eventf(format string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func FatalIf added in v1.3.31

func FatalIf(args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func Fatalln

func Fatalln(args ...interface{})

func IgnoreErrf added in v1.3.67

func IgnoreErrf(err error, ctxFormat string, ctxArgs ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(format string, args ...interface{})

func Infoln

func Infoln(args ...interface{})

func LevelToString

func LevelToString(level logrus.Level) string

Convert the Level to a string. E.g. PanicLevel becomes "panic".

func Panic

func Panic(args ...interface{})

func Panicf

func Panicf(format string, args ...interface{})

func Panicln

func Panicln(args ...interface{})

func Print

func Print(args ...interface{})

func Printf

func Printf(format string, args ...interface{})

func Println

func Println(args ...interface{})

func Set

func Set(out io.Writer)

func SetFormatter

func SetFormatter(formatter logrus.Formatter)

func SetLevel

func SetLevel(level logrus.Level)

func SetLevelStr

func SetLevelStr(level string) error

func SetLoggerFormatter

func SetLoggerFormatter(lo *Logger, formatter logrus.Formatter)

func SetLoggerLevel

func SetLoggerLevel(lo *Logger, level string) error

func SetOutput

func SetOutput(out io.Writer)

func StdoutPrintf

func StdoutPrintf(format string, args ...interface{})

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(format string, args ...interface{})

func Warning

func Warning(args ...interface{})

func Warningf

func Warningf(format string, args ...interface{})

func Warningln

func Warningln(args ...interface{})

func Warnln

func Warnln(args ...interface{})

func WithError

func WithError(err error) *logrus.Entry

func WithField

func WithField(key string, value interface{}) *logrus.Entry

func WithFields

func WithFields(fields logrus.Fields) *logrus.Entry

func WithModule added in v1.3.85

func WithModule(value interface{}) *logrus.Entry

Types

type FileConfig

type FileConfig struct {
	Filename string `vx_default:"main"`

	// MaxSize is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 100 megabytes.
	MaxSize int `vx_default:"10"`

	// MaxAge is the maximum number of days to retain old log files based on the
	// timestamp encoded in their filename.  Note that a day is defined as 24
	// hours and may not exactly correspond to calendar days due to daylight
	// savings, leap seconds, etc. The default is not to remove old log files
	// based on age.
	MaxAge int `vx_default:"7"`

	// MaxBackups is the maximum number of old log files to retain.  The default
	// is to retain all old log files (though MaxAge may still cause them to get
	// deleted.)
	MaxBackups int `vx_default:"5"`

	// LocalTime determines if the time used for formatting the timestamps in
	// backup files is the computer's local time.  The default is to use UTC
	// time.
	LocalTime bool `vx_default:"true"`

	// Compress determines if the rotated log files should be compressed
	// using gzip. The default is not to perform compression.
	Compress bool `vx_default:"true"`
}

type Logger added in v1.3.48

type Logger struct {
	*logrus.Logger
}

func New

func New() *Logger

func NewLogger

func NewLogger(pCtx context.Context, cfg FileConfig) *Logger

func SetLoggerOutput

func SetLoggerOutput(lo *Logger, pCtx context.Context, cfg FileConfig) *Logger

func StandardLogger

func StandardLogger() *Logger

type TextFormatter

type TextFormatter struct {
	// Set to true to bypass checking for a TTY before outputting colors.
	ForceColors bool

	// Force disabling colors.
	DisableColors bool

	// Disable timestamp logging. useful when output is redirected to logging
	// system that already adds timestamps.
	DisableTimestamp bool

	// TimestampFormat to use for display when a full timestamp is printed
	TimestampFormat string

	// The fields are sorted by default for a consistent output. For applications
	// that log extremely frequently and don't use the JSON formatter this may not
	// be desired.
	DisableSorting bool

	// Disables the truncation of the level text to 4 characters.
	DisableLevelTruncation bool

	// QuoteEmptyFields will wrap empty fields in quotes if true
	QuoteEmptyFields bool

	// Show Field Keys
	// true:  time="2020-02-22T21:33:31+08:00" level=info msg="File read done:conf/input!"
	// false: "2020-02-22T21:42:57+08:00" info "Start all services..."
	EnableFieldKey bool

	// skip frame in callstack when get FileLine
	SkipFrames int

	// show file:line
	DisableFileLine bool

	// show packge.(class).FuncName
	EnableFuncName bool

	// if with File, the path depth of the file name shown
	// 2 by default
	// for aaa/bbb/ccc/ddd/file.go, 2 means ddd/file.go, 1 means file.go.
	FilePathDepth int

	// need quote
	EnableQuoting bool

	sync.Once
	// contains filtered or unexported fields
}

TextFormatter formats logs into text

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format renders a single log entry

Jump to

Keyboard shortcuts

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