log

package
v1.3.36 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 13 Imported by: 0

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 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 New

func New() *logrus.Logger

func NewLogger

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

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 *logrus.Logger, formatter logrus.Formatter)

func SetLoggerLevel

func SetLoggerLevel(lo *logrus.Logger, level string) error

func SetLoggerOutput

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

func SetOutput

func SetOutput(out io.Writer)

func StandardLogger

func StandardLogger() *logrus.Logger

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

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 LoggerIf

type LoggerIf interface {
	SetOutput(output io.Writer)
}

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

	// show file:line
	DisableFileLine bool

	// 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