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

Package log provides lightweight logging utilities for gorp framework. Attaches request-scoped loggers to context for middleware and handler flows. Supports deriving per-request field-enriched loggers without mutating global default.

日志包提供 gorp 框架的轻量日志工具能力。 在 context 中挂载请求级 logger,供 middleware 和 handler 流程使用。 支持在不修改全局默认 logger 的前提下派生带请求字段的 logger。

Package log provides lightweight logging utilities for gorp framework. This file manages process-wide default logger used across the framework. Keeps default logger reads and writes concurrency-safe with noop fallback.

日志包提供 gorp 框架的轻量日志工具能力。 本文件管理框架全局使用的进程级默认 logger。 保证默认 logger 的读写具备并发安全,提供 noop 回退。

Package log provides lightweight logging utilities for gorp framework. This file provides field builders and default-logger helpers for logging. Offers centralized utility layer above the observability logger contract.

日志包提供 gorp 框架的轻量日志工具能力。 本文件提供轻量字段构造器和默认 logger helper。 在 observability 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 context logger or falls back to the default logger.

Ctx 返回 context logger;若不存在则回退到默认 logger。

func Debug

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

Debug writes a debug log through the process-wide default logger.

Debug 通过进程级默认 logger 输出 debug 日志。

func Default

func Default() observabilitycontract.Logger

Default returns the process-wide default logger.

Default 返回进程级默认 logger。

func Err

Err creates the standard error field.

Err 构造标准错误字段。

func Error

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

Error writes an error log through the process-wide default logger.

Error 通过进程级默认 logger 输出 error 日志。

func FromContext

func FromContext(ctx context.Context) (observabilitycontract.Logger, bool)

FromContext reads the logger stored in the context.

FromContext 从 context 中读取 logger。

func Info

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

Info writes an info log through the process-wide default logger.

Info 通过进程级默认 logger 输出 info 日志。

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 replaces 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 through the process-wide default logger.

Warn 通过进程级默认 logger 输出 warn 日志。

func With

With derives a logger from the default logger and appends extra fields.

With 基于默认 logger 派生一个追加了字段的新 logger。

func WithContext

WithContext stores one logger into the context.

WithContext 将一个 logger 写入 context。

func WithContextFields

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

WithContextFields derives a logger from the context logger and appends fields.

WithContextFields 基于 context logger 派生一个追加了字段的新 logger。

Types

This section is empty.

Jump to

Keyboard shortcuts

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