klogger

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLogFunc

type AppLogFunc func(lvl Level, f string, args ...any)

type AppLogFuncWithTag

type AppLogFuncWithTag func(lvl Level, tag string, f string, args ...any)

type Level

type Level int8
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel Level = iota - 1
	// InfoLevel is the default logging priority.
	InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel
)

func (Level) String

func (l Level) String() string

type Logger

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

func AsyncLoggerInstance added in v0.5.2

func AsyncLoggerInstance(filename string, logLevel int8, needConsole bool, async bool, flushInterval, bufferSize int64, needTerminalColor bool) *Logger

func GetLoggerWithConfig

func GetLoggerWithConfig(conf *LoggerConfigure) *Logger

func LoggerInstance

func LoggerInstance(filename string, logLevel int8, needConsole bool, async bool, needTerminalColor bool) *Logger

func LoggerInstanceOnlyConsole

func LoggerInstanceOnlyConsole(logLevel int8) *Logger

func LoggerInstanceWithoutConsole

func LoggerInstanceWithoutConsole(filename string, async bool, logLevel int8) *Logger

var log *zap.Logger

func (*Logger) D

func (that *Logger) D(template string, args ...any)

func (*Logger) DP

func (that *Logger) DP(template string, args ...any)

func (*Logger) DPanic

func (that *Logger) DPanic(template string, args ...any)

func (*Logger) Debug

func (that *Logger) Debug(template string, args ...any)

func (*Logger) E

func (that *Logger) E(template string, args ...any)

func (*Logger) Error

func (that *Logger) Error(template string, args ...any)

func (*Logger) F

func (that *Logger) F(template string, args ...any)

func (*Logger) Fatal

func (that *Logger) Fatal(template string, args ...any)

func (*Logger) I

func (that *Logger) I(template string, args ...any)

func (*Logger) Info

func (that *Logger) Info(template string, args ...any)

func (*Logger) KD

func (that *Logger) KD(skip int, template string, args ...any)

func (*Logger) KDP

func (that *Logger) KDP(skip int, template string, args ...any)

func (*Logger) KDPanic

func (that *Logger) KDPanic(skip int, template string, args ...any)

func (*Logger) KDebug

func (that *Logger) KDebug(skip int, template string, args ...any)

func (*Logger) KE

func (that *Logger) KE(skip int, template string, args ...any)

func (*Logger) KError

func (that *Logger) KError(skip int, template string, args ...any)

func (*Logger) KF

func (that *Logger) KF(skip int, template string, args ...any)

func (*Logger) KFatal

func (that *Logger) KFatal(skip int, template string, args ...any)

func (*Logger) KI

func (that *Logger) KI(skip int, template string, args ...any)

func (*Logger) KInfo

func (that *Logger) KInfo(skip int, template string, args ...any)

func (*Logger) KW

func (that *Logger) KW(skip int, template string, args ...any)

func (*Logger) KWarrn

func (that *Logger) KWarrn(skip int, template string, args ...any)

func (*Logger) Sync added in v0.4.5

func (that *Logger) Sync()

func (*Logger) W

func (that *Logger) W(template string, args ...any)

func (*Logger) Warrn

func (that *Logger) Warrn(template string, args ...any)

type LoggerConfigure

type LoggerConfigure struct {
	Level    Level `json:"logLevel"` // 日志等级
	Colorful bool  `json:"colorful"` // 是否需要彩色
	Async    bool  `json:"async"`    // 是否异步输出日志, 默认同步输出

	MaxAge       int    `json:"maxAge"`       // 日志最长保留时间, 单位 小时
	MaxSize      int64  `json:"maxSize"`      // 单文件最大滚动大小, 单位 byte, 超过后强制滚动
	RotationTime int    `json:"rotationTime"` // 日志滚动周期, 单位 小时, 24小时滚动一个文件
	ToConsole    bool   `json:"console"`      // 是否输出到控制台
	LogFile      string `json:"logFile"`      // 输出到文件, 如果文件名为空, 则不输出到文件
	// contains filtered or unexported fields
}

func NewConfigure

func NewConfigure() *LoggerConfigure

func (*LoggerConfigure) BufferSize added in v0.5.2

func (that *LoggerConfigure) BufferSize() int64

func (*LoggerConfigure) FlushInterval added in v0.5.2

func (that *LoggerConfigure) FlushInterval() int64

func (*LoggerConfigure) IsColorful

func (that *LoggerConfigure) IsColorful(need bool) *LoggerConfigure

func (*LoggerConfigure) SetAsync added in v0.4.5

func (that *LoggerConfigure) SetAsync(async bool, flushInterval, bufferSize int64) *LoggerConfigure

func (*LoggerConfigure) SetLevel

func (that *LoggerConfigure) SetLevel(level Level) *LoggerConfigure

func (*LoggerConfigure) SetLogFile

func (that *LoggerConfigure) SetLogFile(file string) *LoggerConfigure

设置日志输出文件, 如果文件名为空, 则不输出到文件

func (*LoggerConfigure) SetMaxAge

func (that *LoggerConfigure) SetMaxAge(age int) *LoggerConfigure

func (*LoggerConfigure) SetMaxSize added in v0.5.5

func (that *LoggerConfigure) SetMaxSize(size int64) *LoggerConfigure

设置单文件最大滚动大小, 单位 byte, 超过后强制滚动, 默认10G

func (*LoggerConfigure) SetRotationTime

func (that *LoggerConfigure) SetRotationTime(time int) *LoggerConfigure

设置日志滚动时间, 单位 小时, 默认720小时(30天)

func (*LoggerConfigure) ShowConsole

func (that *LoggerConfigure) ShowConsole(flag bool) *LoggerConfigure

设置是否输出到控制台

Jump to

Keyboard shortcuts

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