log

package
v0.0.0-...-80248e1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey = "TID" // 日志traceId key, value 为 string
	UserIDKey  = "UID" // 日志用户ID key, value 为 uint64
)
View Source
const (
	LevelOff   uint32 = 0 //关闭
	LevelFatal uint32 = 1 //致命
	LevelError uint32 = 2 //错误
	LevelWarn  uint32 = 3 //警告
	LevelInfo  uint32 = 4 //信息
	LevelDebug uint32 = 5 //调试
	LevelTrace uint32 = 6 //跟踪
	LevelOn    uint32 = 7 //全部打开
)

日志等级

Variables

This section is empty.

Functions

func GetLevelDesc

func GetLevelDesc(level uint32) string

获取等级描述

func NewOptions

func NewOptions() *options

NewOptions 新的Options

func PrintErr

func PrintErr(v ...any)

PrintErr 输出到os.Stderr

func PrintInfo

func PrintInfo(v ...any)

PrintInfo 输出到os.Stdout

func PrintfErr

func PrintfErr(format string, v ...any)

PrintfErr 输出到os.Stderr

func PrintfInfo

func PrintfInfo(format string, v ...any)

PrintfInfo 输出到os.Stdout

Types

type ExtendFields

type ExtendFields []any // key,val 数组

ExtendFields 扩展字段,日志数据字段

type ILog

type ILog interface {
	GetLevel() uint32
	SetLevel(level uint32) error
	Stop() error
	Trace(v ...any)
	TraceExtend(ctx context.Context, extendFields ExtendFields, v ...any)
	Tracef(format string, v ...any)
	TracefExtend(ctx context.Context, extendFields ExtendFields, format string, v ...any)
	Debug(v ...any)
	DebugExtend(ctx context.Context, extendFields ExtendFields, v ...any)
	DebugLazy(vFunc func() []any)
	Debugf(format string, v ...any)
	DebugfExtend(ctx context.Context, extendFields ExtendFields, format string, v ...any)
	DebugfLazy(formatFunc func() (string, []any))
	Info(v ...any)
	InfoExtend(ctx context.Context, extendFields ExtendFields, v ...any)
	Infof(format string, v ...any)
	InfofExtend(ctx context.Context, extendFields ExtendFields, format string, v ...any)
	Warn(v ...any)
	WarnExtend(ctx context.Context, extendFields ExtendFields, v ...any)
	Warnf(format string, v ...any)
	WarnfExtend(ctx context.Context, extendFields ExtendFields, format string, v ...any)
	Error(v ...any)
	ErrorExtend(ctx context.Context, extendFields ExtendFields, v ...any)
	Errorf(format string, v ...any)
	ErrorfExtend(ctx context.Context, extendFields ExtendFields, format string, v ...any)
	Fatal(v ...any)
	FatalExtend(ctx context.Context, extendFields ExtendFields, v ...any)
	Fatalf(format string, v ...any)
	FatalfExtend(ctx context.Context, extendFields ExtendFields, format string, v ...any)
}
var GLog ILog

func NewMgr

func NewMgr(opts ...*options) (ILog, error)

NewMgr 创建日志管理器

Jump to

Keyboard shortcuts

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