internal

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset    = "\033[0m"
	ColorYellow   = "\033[33m"
	ColorBlueBold = "\033[34;1m"
	ColorRedBold  = "\033[31;1m"
	ColorGreen    = "\033[32m"
)

ANSI Color Constants

View Source
const (
	// LogTypeMongo 为日志类型标识(供下游聚合检索)。
	LogTypeMongo = 6
	// ResultSuccess 为成功执行的结果标记。
	ResultSuccess = "success"

	// HeaderPrefix Firefly系统自定义头部(统一前缀)
	HeaderPrefix = "x-firefly-"
	// TraceId 为从 metadata 读取 trace id 的 key
	TraceId = HeaderPrefix + "trace-id"
	// SpanId 为从 metadata 读取 span id 的 key
	SpanId = HeaderPrefix + "span-id"

	// UserId 为从 metadata 读取 user id 的 key
	UserId = HeaderPrefix + "user-id"
	// AppId 为从 metadata 读取 app id 的 key
	AppId = HeaderPrefix + "app-id"
)

Log Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	// Console 控制是否输出到控制台。
	Console bool
	// SlowThreshold 为慢查询阈值。
	SlowThreshold time.Duration
	// Colorful 控制是否启用彩色输出。
	Colorful bool
	// Database 为库名字段,用于检索与聚合。
	Database string
}

Conf 为 logger 的配置。

type Interface

type Interface interface {
	// Trace 记录一次命令的执行信息。
	Trace(ctx context.Context, id int64, elapsed time.Duration, smt string, err string)
}

Interface 约束 logger 需要提供的能力。

func NewLogger

func NewLogger(conf *Conf, handle func([]byte)) Interface

NewLogger 构造一个新的 logger,并按配置决定输出模板。

type LogLevel

type LogLevel uint32

LogLevel 定义日志级别枚举。

const (
	Info  LogLevel = 1 // Info 普通级别。
	Warn  LogLevel = 2 // Warn 警告级别。
	Error LogLevel = 3 // Error 错误级别。
)

type OperationLogger added in v0.6.2

type OperationLogger struct {
	Database  string `json:"database"`
	Statement string `json:"statement"`
	Result    string `json:"result"`
	Path      string `json:"path"`

	Duration uint64 `json:"duration"`

	Level uint32 `json:"level"`
	Type  uint32 `json:"type"`

	TraceId  string `json:"trace_id"`
	ParentId string `json:"parent_id"`

	UserId      string `json:"user_id"`
	TargetAppId string `json:"target_app_id"`
	InvokeAppId string `json:"invoke_app_id"`
}

OperationLogger 表示操作日志。

Jump to

Keyboard shortcuts

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