logs

package
v0.0.0-...-15b6c9a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxDebug

func CtxDebug(ctx context.Context, msg string, args ...any)

CtxDebug 从 context 中获取 logger 并记录 debug 日志

func CtxError

func CtxError(ctx context.Context, msg string, args ...any)

CtxError 从 context 中获取 logger 并记录 error 日志

func CtxInfo

func CtxInfo(ctx context.Context, msg string, args ...any)

CtxInfo 从 context 中获取 logger 并记录 info 日志

func CtxWarn

func CtxWarn(ctx context.Context, msg string, args ...any)

CtxWarn 从 context 中获取 logger 并记录 warn 日志

func Debug

func Debug(msg string, args ...any)

Debug 记录 debug 级别的日志

func Debugf

func Debugf(format string, args ...any)

Debugf 记录格式化的 debug 级别日志

func Error

func Error(msg string, args ...any)

Error 记录 error 级别的日志

func Errorf

func Errorf(format string, args ...any)

Errorf 记录格式化的 error 级别日志

func FromContext

func FromContext(ctx context.Context) *slog.Logger

FromContext 从 context 中获取 logger 如果 context 中没有,则返回全局默认 logger

func Info

func Info(msg string, args ...any)

Info 记录 info 级别的日志

func Infof

func Infof(format string, args ...any)

Infof 记录格式化的 info 级别日志

func Init

func Init(c *config.LogConfig)

Init 初始化全局日志记录器 这是应用启动时应该调用的第一个函数

func Warn

func Warn(msg string, args ...any)

Warn 记录 warn 级别的日志

func Warnf

func Warnf(format string, args ...any)

Warnf 记录格式化的 warn 级别日志

func WithContext

func WithContext(ctx context.Context, args ...any) context.Context

WithContext 将一个带有附加属性的 logger 存入 context 并返回新的 context 在中间件中使用,为每个请求添加 request_id 等信息

Types

This section is empty.

Jump to

Keyboard shortcuts

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