logger

package
v0.0.59 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 6 Imported by: 15

Documentation

Index

Constants

View Source
const (
	PanicLevel Level = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
	TraceLevel

	ConsoleLogger Type = 1
	FileLogger    Type = 2
)

Variables

This section is empty.

Functions

func EnableConsole added in v0.0.25

func EnableConsole(level Level, disableColor ...bool)

EnableConsole 启用该设置后,日志内容将向标准控台输出

func EnableConsoleWithFormatter added in v0.0.56

func EnableConsoleWithFormatter(level Level, formatter *formatter)

EnableConsoleWithFormatter 启用该设置后,日志内容将向标准控台输出

func EnableFileWithFormatter added in v0.0.56

func EnableFileWithFormatter(level Level, formatter *formatter, fileConfig ...*lumberjack.Logger)

EnableFileWithFormatter 启用该配置后写入日志文件,将日志输出为指定格式 如果要使用console+file需要先初始化Console配置

func EnableFileWithJson added in v0.0.25

func EnableFileWithJson(level Level, fileConfig ...*lumberjack.Logger)

EnableFileWithJson 启用该配置后将写入日志文件,并将日志输出json格式 如果要使用console+file需要先初始化Console配置

func EnableFileWithText added in v0.0.25

func EnableFileWithText(level Level, fileConfig ...*lumberjack.Logger)

EnableFileWithText 启用该配置后写入日志文件,将日志输出为text格式 如果要使用console+file需要先初始化Console配置

func IsLevelEnabled added in v0.0.57

func IsLevelEnabled(level Level, logType ...Type) bool

IsLevelEnabled 判断指定级别是否启用 优先以fileLogger实例的状态判断

func Logrus

func Logrus() *logrus.Logger

Logrus 获取logrus实例

func NewFormatter added in v0.0.59

func NewFormatter(formatterFn func(traceSupplier TraceIdSupplier, entry *logrus.Entry) ([]byte, error)) *formatter

NewFormatter 创建一个自定义格式化器

func RawConsoleLogger added in v0.0.57

func RawConsoleLogger() *logrus.Logger

RawConsoleLogger 获取原始控制台日志实例

func RawFileLogger added in v0.0.57

func RawFileLogger() *logrus.Logger

RawFileLogger 获取原始文件日志实例

func SetTraceIdSupplier added in v0.0.53

func SetTraceIdSupplier(supplier TraceIdSupplier)

SetTraceIdSupplier 设置TraceIdSupplier

Types

type Level added in v0.0.25

type Level uint32

type TraceIdSupplier added in v0.0.53

type TraceIdSupplier interface {
	GetTraceId() string
	SetTraceId(string)
}

TraceIdSupplier 生成日志跟踪id

type Type added in v0.0.59

type Type int8

Jump to

Keyboard shortcuts

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