logs

package
v0.0.0-...-f282eec Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLogPath = "./runtime/logs/app.log"

Variables

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

LogLevelMap 兼容旧配置

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

Functions

func NewNullLog

func NewNullLog() *writerLog

func NewTestingLog

func NewTestingLog(t testing.TB, level LogLevel) *testingLog

func NewWriterLog

func NewWriterLog(w io.Writer, level LogLevel, cs ...*configstc.LogConfig) *writerLog

func SetLogger

func SetLogger(log ILog)

Types

type DefaultZapLog

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

DefaultZapLog default logger

func NewWithZapLog

func NewWithZapLog(zlog *zap.Logger) *DefaultZapLog

func NewZapLog

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

func (*DefaultZapLog) Caller

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

func (*DefaultZapLog) CallerSkip

func (l *DefaultZapLog) CallerSkip(offset int) ILog

func (*DefaultZapLog) Ctl

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

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

type ILog

type ILog interface {
	ILogWriter

	ILogCtr
	ILogCallerSkip
}
var (
	Out ILog = NewWriterLog(os.Stdout, DebugLog)
)

全局logger

func NewDefaultLogger

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

type ILogCallerSkip

type ILogCallerSkip interface {
	CallerSkip(offset int) ILog
}

type ILogCtr

type ILogCtr interface {
	Ctl(bool) ILog
}

type ILogWriter

type ILogWriter 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)
}

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) Caller

func (ink *InvokeLog) Caller(skip int) ILog

func (*InvokeLog) CallerSkip

func (ink *InvokeLog) CallerSkip(skip int) ILog

func (*InvokeLog) Ctl

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

func (ink *InvokeLog) GetLogger() ILog

func (*InvokeLog) Info

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

func (*InvokeLog) Log

func (ink *InvokeLog) Log(level LogLevel, 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

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

type LogLevel

type LogLevel int
const (
	DebugLog LogLevel = iota
	TraceLog
	InfoLog
	WarnLog
	ErrorLog
	PanicLog
	FatalLog
)

func NameToLogLevel

func NameToLogLevel(s string) LogLevel

func (LogLevel) String

func (l LogLevel) String() string

type MyLogger

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

MyLogger 日志

func (*MyLogger) Caller

func (l *MyLogger) Caller(offset int) ILog

func (*MyLogger) CallerSkip

func (l *MyLogger) CallerSkip(offset int) ILog

func (*MyLogger) Ctl

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