log

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Application scenarios: - Expose the framework logging capability through a short top-level package. - Re-export common logger helpers so business code does not need to import the internal framework/log package directly. - Provide convenient field builders and context-related logger accessors.

适用场景: - 通过简短的顶层包暴露框架日志能力。 - 重新导出常用 logger helper,让业务代码不必直接 import 内部的 framework/log 包。 - 提供便捷的字段构造器和 context 相关 logger 访问入口。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(key string, value any) observabilitycontract.Field

Any creates a generic log field.

Any 构造任意类型字段。

func Bool

func Bool(key string, value bool) observabilitycontract.Field

Bool creates a bool log field.

Bool 构造 bool 字段。

func Ctx

Ctx returns the logger associated with the context.

Ctx 返回当前 context 关联的 logger。

func Debug

func Debug(msg string, fields ...observabilitycontract.Field)

Debug writes a debug log with the default logger.

Debug 使用默认 logger 输出 debug 日志。

func Default

func Default() observabilitycontract.Logger

Default returns the process-wide default logger.

Default 返回进程级默认 logger。

func Err

Err creates an error log field.

Err 构造错误字段。

func Error

func Error(msg string, fields ...observabilitycontract.Field)

Error writes an error log with the default logger.

Error 使用默认 logger 输出 error 日志。

func Info

func Info(msg string, fields ...observabilitycontract.Field)

Info writes an info log with the default logger.

Info 使用默认 logger 输出 info 日志。

Example:

log.Info("user created", log.Int64("user_id", 42), log.String("source", "signup"))

func Int

func Int(key string, value int) observabilitycontract.Field

Int creates an int log field.

Int 构造 int 字段。

func Int64

func Int64(key string, value int64) observabilitycontract.Field

Int64 creates an int64 log field.

Int64 构造 int64 字段。

func SetDefault

func SetDefault(l observabilitycontract.Logger)

SetDefault sets the process-wide default logger.

SetDefault 设置进程级默认 logger。

func String

func String(key, value string) observabilitycontract.Field

String creates a string log field.

String 构造字符串字段。

func Warn

func Warn(msg string, fields ...observabilitycontract.Field)

Warn writes a warn log with the default logger.

Warn 使用默认 logger 输出 warn 日志。

func With

With returns a logger derived from the default logger with extra fields.

With 在默认 logger 基础上附加字段。

func WithContext

WithContext stores a request-scoped logger into the context.

WithContext 将请求级 logger 写入 context。

func WithContextFields

func WithContextFields(ctx context.Context, fields ...observabilitycontract.Field) observabilitycontract.Logger

WithContextFields appends fields to the logger associated with the context.

WithContextFields 基于 context 关联的 logger 追加字段。

Types

This section is empty.

Jump to

Keyboard shortcuts

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