klog

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMapToCtx

func AddMapToCtx(ctx context.Context, kv map[string]string) context.Context

AddMapToCtx 追加参数 - map

func AddToCtx

func AddToCtx(ctx context.Context, key string, val string) context.Context

AddToCtx 追加参数

func ColorPrint

func ColorPrint(ctx context.Context, color Color, v ...any)

ColorPrint 彩色打印日志

func Debug

func Debug(ctx context.Context, v ...any)

Debug 打印日志

func DefaultHandler

func DefaultHandler(ctx context.Context, in *glog.HandlerInput)

DefaultHandler 默认日志处理

func Error

func Error(ctx context.Context, v ...any)

Error 打印错误级日志

func Info

func Info(ctx context.Context, v ...any)

Info 打印日志

func Init

func Init()

初始化日志

func Logger

func Logger(name ...string) *glog.Logger

Logger 获取指定名称的日志实例,若名称为空则返回默认实例

name - 日志实例名称(对应配置中的日志名称)
返回:*glog.Logger 日志实例

func Notice

func Notice(ctx context.Context, v ...any)

Notice 打印日志

func Panic

func Panic(ctx context.Context, v ...any)

Panic 打印日志

func Print

func Print(ctx context.Context, v ...any)

Print 打印日志

func Warn

func Warn(ctx context.Context, v ...any)

Warn 打印警告级日志(原 Warning 重命名,对齐 glog 命名)

Types

type Color

type Color int

Color 颜色

type Log

type Log struct {
	Time     string
	Level    string
	LevelInt int
	TraceID  string
	Body     []any
	Add      map[string]string
}

Log 日志结构体

func (*Log) String

func (l *Log) String() string

String 格式化日志

Jump to

Keyboard shortcuts

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