logger

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 12 Imported by: 0

README

logger

一个logrus的修饰器,增加了一个写日志文件的接口

Documentation

Index

Constants

View Source
const (
	TraceLevel = logrus.TraceLevel
	DebugLevel = logrus.DebugLevel
	InfoLevel  = logrus.InfoLevel
	WarnLevel  = logrus.WarnLevel
	ErrorLevel = logrus.ErrorLevel
	FatalLevel = logrus.FatalLevel
	PanicLevel = logrus.PanicLevel
)

Variables

View Source
var Logger *logrus.Logger

Functions

func AddFile

func AddFile(filename string, maxAgeDays int)

增加一个文件输出 filename 文件名 maxAgeDays 文件最多保留天数

func AddHook

func AddHook(hook logrus.Hook)

func AddOutput

func AddOutput(writer io.Writer)

func Debug

func Debug(args ...interface{})

func DebugFn

func DebugFn(fn logrus.LogFunction)

func Debugf

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

func Debugln

func Debugln(args ...interface{})

func Error

func Error(args ...interface{})

func ErrorFn

func ErrorFn(fn logrus.LogFunction)

func Errorf

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

func Errorln

func Errorln(args ...interface{})

func Exit

func Exit(code int)

func Fatal

func Fatal(args ...interface{})

func FatalFn

func FatalFn(fn logrus.LogFunction)

func Fatalf

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

func Fatalln

func Fatalln(args ...interface{})

func Info

func Info(args ...interface{})

func InfoFn

func InfoFn(fn logrus.LogFunction)

func Infof

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

func Infoln

func Infoln(args ...interface{})

func IsLevelEnabled

func IsLevelEnabled(level Level) bool

func Log

func Log(level Level, args ...interface{})

func LogFn

func LogFn(level Level, fn logrus.LogFunction)

func Logf

func Logf(level Level, format string, args ...interface{})

func Logln

func Logln(level Level, args ...interface{})

func Panic

func Panic(args ...interface{})

func PanicFn

func PanicFn(fn logrus.LogFunction)

func Panicf

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

func Panicln

func Panicln(args ...interface{})

func Print

func Print(args ...interface{})

func PrintFn

func PrintFn(fn logrus.LogFunction)

func Printf

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

func Println

func Println(args ...interface{})

func ReplaceHooks

func ReplaceHooks(hooks logrus.LevelHooks) logrus.LevelHooks

func SetFormatter

func SetFormatter(formatter logrus.Formatter)

func SetLevel

func SetLevel(level Level)

func SetNoLock

func SetNoLock()

func SetOutput

func SetOutput(output io.Writer)

func SetReportCaller

func SetReportCaller(reportCaller bool)

func Trace

func Trace(args ...interface{})

func TraceFn

func TraceFn(fn logrus.LogFunction)

func Tracef

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

func Traceln

func Traceln(args ...interface{})

func Warn

func Warn(args ...interface{})

func WarnFn

func WarnFn(fn logrus.LogFunction)

func Warnf

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

func Warning

func Warning(args ...interface{})

func WarningFn

func WarningFn(fn logrus.LogFunction)

func Warningf

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

func Warningln

func Warningln(args ...interface{})

func Warnln

func Warnln(args ...interface{})

func WithContext

func WithContext(ctx context.Context) *logrus.Entry

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 WithTime

func WithTime(t time.Time) *logrus.Entry

Types

type ColorCleaner

type ColorCleaner struct {
	Writer io.Writer
}

func (*ColorCleaner) Write

func (c *ColorCleaner) Write(p []byte) (n int, err error)

type Formatter

type Formatter struct {
	TimestampFormat  string
	CallerPrettyfier func(*runtime.Frame) (ret string)
	LevelColor       map[logrus.Level]Sprinter
	NoColor          bool
}

Formatter implements logrus.Formatter interface.

func NewFormatter

func NewFormatter() *Formatter

func (*Formatter) Format

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

Format building log message.

type Level

type Level = logrus.Level

func GetLevel

func GetLevel() Level

type Sprinter

type Sprinter interface {
	Sprint(a ...interface{}) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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