log

package
v0.0.0-...-0c35135 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Ldate log date
	Ldate = log.Ldate
	// Ltime log time
	Ltime = log.Ltime
	// Lmicroseconds log microseconds
	Lmicroseconds = log.Lmicroseconds
	// Llongfile long file
	Llongfile = log.Llongfile
	// Lshortfile short file
	Lshortfile = log.Lshortfile
	// LUTC UTC
	LUTC = log.LUTC
	// LstdFlags flags
	LstdFlags = log.LstdFlags
	// PanicLevel panic level
	PanicLevel = int(logrus.PanicLevel)
	// FatalLevel fatal level
	FatalLevel = int(logrus.FatalLevel)
	// ErrorLevel error level
	ErrorLevel = int(logrus.ErrorLevel)
	// WarnLevel warn level
	WarnLevel = int(logrus.WarnLevel)
	// InfoLevel info level
	InfoLevel = int(logrus.InfoLevel)
	// DebugLevel debug level
	DebugLevel = int(logrus.DebugLevel)
)

Variables

View Source
var (
	// 默认配置
	Log        *Logger                   // 默认日志
	LogOut     io.Writer = nil           // !nil: 所有日志也会同时输出到该目录
	LogFlag              = log.Llongfile // 默认输出格式
	IsInDocker bool                      // true: 当前在docker环境
	// rotate options
	RotateSuffix                 = ".%Y%m%d.part"       // 易于识别的后缀
	RotateTime     time.Duration = time.Hour * 24       //
	RotateMaxCount uint          = 365                  //
	RotateMaxAge   time.Duration = -1                   //
	RotateCompress               = gzip.BestCompression //
	//
	RegLevel = regexp.MustCompile("level=([a-z]+)") // 判断日志级别
)

Log flag

View Source
var (
	HookErrorConvert func(interface{}) interface{} = nil
)

Functions

func Debug

func Debug(args ...interface{})

Debug debug

func Debugf

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

Debugf debug

func Debugln

func Debugln(args ...interface{})

Debugln debug

func Error

func Error(args ...interface{})

Error error

func Errorf

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

Errorf error

func Errorln

func Errorln(args ...interface{})

Errorln error

func Fatal

func Fatal(args ...interface{})

Fatal fatal

func Fatalf

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

Fatalf fatal

func Fatalln

func Fatalln(args ...interface{})

Fatalln fatal

func Info

func Info(args ...interface{})

Info info

func Infof

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

Infof info

func Infoln

func Infoln(args ...interface{})

Infoln info

func Panic

func Panic(args ...interface{})

Panic panic

func Panicf

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

Panicf panic

func Panicln

func Panicln(args ...interface{})

Panicln panic

func Print

func Print(args ...interface{})

Print print

func Printf

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

Printf print

func Println

func Println(args ...interface{})

Println print

func PubErrorConvert

func PubErrorConvert(in []interface{}) (out []interface{})

PubErrorConvert 错误转换

func SetFlags

func SetFlags(flg int)

SetFlags log normal

func SetLevel

func SetLevel(level int)

SetLevel log normal

func Warn

func Warn(args ...interface{})

Warn warn

func Warnf

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

Warnf warn

func Warnln

func Warnln(args ...interface{})

Warnln warn

Types

type HookError

type HookError struct {
	Filepath string
	Out      io.WriteCloser
	// contains filtered or unexported fields
}

HookError hook

func (*HookError) Fire

func (h *HookError) Fire(entry *logrus.Entry) (err error)

Fire err

func (*HookError) Levels

func (h *HookError) Levels() []logrus.Level

Levels level

type HookRotate

type HookRotate struct {
	CompressLevel int
}

HookRotate

func (*HookRotate) Handle

func (h *HookRotate) Handle(event rotatelogs.Event)

compress

type Logger

type Logger struct {
	*logrus.Logger

	// local
	Out          io.Writer     // 日志输出
	Name         string        // 日志称呼
	LogFlag      int           // 输出格式 非DEBUG方法
	LogFlagDebug int           // 输出格式 DEBUG方法
	CallerSkip   int           // 定位函数层级
	Entry        *logrus.Entry //
	// contains filtered or unexported fields
}

Logger log struct

func NewLog

func NewLog(s *Logger) (d *Logger)

NewLog new

func NewLogFile

func NewLogFile(logPath string) (d *Logger)

NewLogFile new log file

func (*Logger) Close

func (l *Logger) Close() (err error)

func (*Logger) Copy

func (l *Logger) Copy() (r *Logger)

Copy 复制

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug debug

func (*Logger) Debugf

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

Debugf debug

func (*Logger) Debugln

func (l *Logger) Debugln(args ...interface{})

Debugln debug

func (*Logger) EntryWith

func (l *Logger) EntryWith(flg int, callerSkip int) (ret *logrus.Entry)

EntryWith 格式化输出

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error error

func (*Logger) Errorf

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

Errorf error

func (*Logger) Errorln

func (l *Logger) Errorln(args ...interface{})

Errorln error

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal fatal

func (*Logger) Fatalf

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

Fatalf fatal

func (*Logger) Fatalln

func (l *Logger) Fatalln(args ...interface{})

Fatalln fatal

func (*Logger) GetLevel

func (l *Logger) GetLevel() int

GetLevel log normal

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info info

func (*Logger) Infof

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

Infof info

func (*Logger) Infoln

func (l *Logger) Infoln(args ...interface{})

Infoln info

func (*Logger) Output

func (l *Logger) Output(callDepth int, s string) (err error)

Output

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

Panic panic

func (*Logger) Panicf

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

Panicf panic

func (*Logger) Panicln

func (l *Logger) Panicln(args ...interface{})

Panicln panic

func (*Logger) Print

func (l *Logger) Print(args ...interface{})

Print print

func (*Logger) Printf

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

Printf print

func (*Logger) Println

func (l *Logger) Println(args ...interface{})

Println print

func (*Logger) SetFlags

func (l *Logger) SetFlags(flg int)

SetFlags log normal

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

SetLevel log normal

func (*Logger) Upon

func (l *Logger) Upon(level int) (ret bool)

Upon up on

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn warn

func (*Logger) Warnf

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

Warnf warn

func (*Logger) Warnln

func (l *Logger) Warnln(args ...interface{})

Warnln warn

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

func (*Logger) Write

func (l *Logger) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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