log

package
v0.0.0-...-3e0e934 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0, BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package log 提供统一的日志包装和上下文管理

核心功能: 1. CubeWrapperLogEntry - 对 CubeLog.Entry 的包装,提供便利的日志方法 2. Context 集成 - 支持通过 context 传递和获取 logger 实例 3. 日志桥接 - 将 klog、logrus、containerd log 统一到 CubeLog

使用示例:

// 获取当前上下文的 logger
logger := log.GetLogger(ctx)
logger.WithField("request_id", "123").Info("message")

// 创建新的上下文并关联 logger
newCtx := log.WithLogger(ctx, logger)
// 新上下文中的日志都会使用这个 logger

日志链路:

业务代码 (CubeLog.Entry)
    ↓
CubeWrapperLogEntry (本包)
    ↓
context 传递与关联
    ↓
klog/logrus/containerd log 桥接
    ↓
日志文件输出

Index

Constants

View Source
const (
	LogFiledPrefix = "LogIndex"

	MaxFieldValueLength = 100
)

Variables

View Source
var AuditLogger *CubeLog.Logger = CubeLog.GetDefaultLogger()

Functions

func IsDebug

func IsDebug() bool

func ReNewLogger

func ReNewLogger(ctx context.Context) context.Context

func SetContainerdLog

func SetContainerdLog()

func SetKlog

func SetKlog()

func WithDebugStack

func WithDebugStack() string

func WithJsonValue

func WithJsonValue(obj any) string

Types

type CubeWrapperLogEntry

type CubeWrapperLogEntry struct {
	*CubeLog.Entry
}

func GetLogger

func GetLogger(ctx context.Context) *CubeWrapperLogEntry

func NewWrapperLogEntry

func NewWrapperLogEntry(entry *CubeLog.Entry) *CubeWrapperLogEntry

func (*CubeWrapperLogEntry) Debug

func (w *CubeWrapperLogEntry) Debug(args ...interface{})

func (*CubeWrapperLogEntry) Debugf

func (w *CubeWrapperLogEntry) Debugf(format string, args ...interface{})

func (*CubeWrapperLogEntry) Error

func (w *CubeWrapperLogEntry) Error(args ...interface{})

func (*CubeWrapperLogEntry) Errorf

func (w *CubeWrapperLogEntry) Errorf(format string, args ...interface{})

func (*CubeWrapperLogEntry) Fatal

func (w *CubeWrapperLogEntry) Fatal(args ...interface{})

func (*CubeWrapperLogEntry) Fatalf

func (w *CubeWrapperLogEntry) Fatalf(format string, args ...interface{})

func (*CubeWrapperLogEntry) Info

func (w *CubeWrapperLogEntry) Info(args ...interface{})

func (*CubeWrapperLogEntry) Infof

func (w *CubeWrapperLogEntry) Infof(format string, args ...interface{})

func (*CubeWrapperLogEntry) Tracef

func (w *CubeWrapperLogEntry) Tracef(format string, v ...interface{})

func (*CubeWrapperLogEntry) Warn

func (w *CubeWrapperLogEntry) Warn(args ...interface{})

func (*CubeWrapperLogEntry) Warnf

func (w *CubeWrapperLogEntry) Warnf(format string, args ...interface{})

func (*CubeWrapperLogEntry) WithError

func (w *CubeWrapperLogEntry) WithError(err error) *CubeWrapperLogEntry

func (*CubeWrapperLogEntry) WithField

func (w *CubeWrapperLogEntry) WithField(key string, value any) *CubeWrapperLogEntry

func (*CubeWrapperLogEntry) WithFields

func (w *CubeWrapperLogEntry) WithFields(fields CubeLog.Fields) *CubeWrapperLogEntry

Jump to

Keyboard shortcuts

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