log

package
v1.1.46 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLog = 1 << iota
	TraceLog
	InfoLog
	WarnLog
	ErrorLog
	PanicLog
	FatalLog
)
View Source
const DefaultLogPath = "./runtime/logs/app.log"

Variables

View Source
var LevelMap = map[int]string{
	TraceLog: "Trace",
	DebugLog: "Debug",
	InfoLog:  "Info",
	WarnLog:  "Warn",
	ErrorLog: "Error",
	FatalLog: "Fatal",
	PanicLog: "Panic",
}
View Source
var LevelMapReverse = map[string]int{}
View Source
var LogLevelMap = LevelMap

LogLevelMap 兼容旧配置

View Source
var ZapLogLevelMap = map[int]zapcore.Level{
	DebugLog: zapcore.DebugLevel,
	InfoLog:  zapcore.InfoLevel,
	WarnLog:  zapcore.WarnLevel,
	ErrorLog: zapcore.ErrorLevel,
	PanicLog: zapcore.PanicLevel,
	FatalLog: zapcore.FatalLevel,
}

Functions

func NewNullLog added in v1.1.43

func NewNullLog() *writerLog

func NewWriterLog added in v1.1.45

func NewWriterLog(w io.Writer, level int, cs ...*config.LogConfig) *writerLog

Types

type DefaultZapLog

type DefaultZapLog struct {
	// contains filtered or unexported fields
}

DefaultZapLog default logger

func NewWithZapLog added in v1.1.46

func NewWithZapLog(zlog *zap.Logger) *DefaultZapLog

func NewZapLog

func NewZapLog(name string, logPath string, cs ...*config.LogConfig) *DefaultZapLog

func (*DefaultZapLog) Caller added in v1.1.39

func (l *DefaultZapLog) Caller(offset int) *DefaultZapLog

func (*DefaultZapLog) Ctl added in v1.1.44

func (l *DefaultZapLog) Ctl(t bool) ILog

func (*DefaultZapLog) Debug

func (l *DefaultZapLog) Debug(format string, params ...interface{})

func (*DefaultZapLog) Error

func (l *DefaultZapLog) Error(format string, params ...interface{})

func (*DefaultZapLog) Fatal

func (l *DefaultZapLog) Fatal(format string, params ...interface{})

func (*DefaultZapLog) Info

func (l *DefaultZapLog) Info(format string, params ...interface{})

func (*DefaultZapLog) Panic

func (l *DefaultZapLog) Panic(format string, params ...interface{})

func (*DefaultZapLog) Warn

func (l *DefaultZapLog) Warn(format string, params ...interface{})

func (DefaultZapLog) Write added in v1.1.45

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

type ILog

type ILog interface {
	Debug(log string, params ...interface{})
	Info(log string, params ...interface{})
	Warn(log string, params ...interface{})
	Error(log string, params ...interface{})
	Panic(log string, params ...interface{})
	Fatal(log string, params ...interface{})
	Write(p []byte) (n int, err error)

	Ctl(bool) ILog //控制是否打印,如 Ctl(true).Warn(...)
}

func NewDefaultLogger

func NewDefaultLogger(name string, cs ...*config.LogConfig) ILog

type InvokeLog

type InvokeLog struct {
	// contains filtered or unexported fields
}

InvokeLog fast use log in struct

func (*InvokeLog) AddLogger

func (ink *InvokeLog) AddLogger(logger ILog)

func (*InvokeLog) Ctl added in v1.1.46

func (ink *InvokeLog) Ctl(t bool) ILog

func (*InvokeLog) Debug

func (ink *InvokeLog) Debug(log string, params ...interface{})

func (*InvokeLog) Error

func (ink *InvokeLog) Error(log string, params ...interface{})

func (*InvokeLog) Fatal

func (ink *InvokeLog) Fatal(log string, params ...interface{})

func (*InvokeLog) GetLogger added in v1.1.43

func (ink *InvokeLog) GetLogger() ILog

func (*InvokeLog) Info

func (ink *InvokeLog) Info(log string, params ...interface{})

func (*InvokeLog) Log

func (ink *InvokeLog) Log(level int8, msg string)

func (*InvokeLog) Panic

func (ink *InvokeLog) Panic(log string, params ...interface{})

func (*InvokeLog) Warn

func (ink *InvokeLog) Warn(log string, params ...interface{})

func (*InvokeLog) Write added in v1.1.46

func (ink *InvokeLog) Write(p []byte) (n int, err error)

type MyLogger

type MyLogger struct {
	// contains filtered or unexported fields
}

MyLogger 日志

func (*MyLogger) Ctl added in v1.1.44

func (l *MyLogger) Ctl(t bool) ILog

func (*MyLogger) Debug

func (l *MyLogger) Debug(format string, params ...interface{})

func (*MyLogger) Error

func (l *MyLogger) Error(format string, params ...interface{})

func (*MyLogger) Fatal

func (l *MyLogger) Fatal(format string, params ...interface{})

func (*MyLogger) Info

func (l *MyLogger) Info(format string, params ...interface{})

func (*MyLogger) LogPath

func (l *MyLogger) LogPath() string

LogPath 最终日志path

func (*MyLogger) Panic

func (l *MyLogger) Panic(format string, params ...interface{})

func (*MyLogger) Warn

func (l *MyLogger) Warn(format string, params ...interface{})

func (*MyLogger) Write

func (l *MyLogger) Write(p []byte) (int, error)

type ZapLogConfig

type ZapLogConfig struct {
	SyncStdOut bool //是否同步输出至标准输出
	MaxSize    int  // 每个日志文件保存的大小 单位:M
	MaxAge     int  // 文件最多保存多少天
	MaxBackups int  // 日志文件最多保存多少个备份
	Compress   bool // 是否压缩

	LogLevel string //日志级别
}

ZapLogConfig 日志配置,已经废弃,请使用config.LogConfig

Jump to

Keyboard shortcuts

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