loggers

package
v5.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Processor
	// 类进程.
	//
	// 获取具体执行器的类进程, 基于此类进程启动/退出服务.
	Processor() process.Processor

	// Publish
	// 发布日志.
	Publish(logs ...Log) error

	// SetFormatter
	// 设置格式.
	SetFormatter(formatter Formatter)
}

Executor 日志执行器.

type Formatter

type Formatter interface {
	// Byte
	// 转字符码.
	Byte(vs ...Log) (body []byte, err error)

	// String
	// 转字符串.
	String(vs ...Log) (string, error)
}

Formatter 格式化.

type Kv

type Kv map[string]interface{}

Kv 日志 Key/Value 键值对.

func (Kv) Add

func (o Kv) Add(key string, value interface{}) Kv

Add 添加 Key/Value 键值对.

.Add("k", 1)
.Add("key", "value")

func (Kv) Copy

func (o Kv) Copy(s Kv) Kv

Copy 复制KV.

func (Kv) String

func (o Kv) String() (str string)

String 转成JSON符串.

{
  "k": 1,
  "key": "value"
}

type Log

type Log interface {
	// Kv
	// Key/Value键值对.
	Kv() Kv

	// Level
	// 日志级别.
	Level() common.Level

	// Stack
	// 堆栈状态.
	Stack() bool

	// Stacks
	// 堆栈列表, 仅当级别为Fatal时有效.
	Stacks() []common.StackItem

	// Text
	// 日志正文.
	Text() string

	// Time
	// 记录时间.
	Time() time.Time

	// SetKv
	// 设置Key/Value键值对.
	SetKv(s Kv) Log
}

Log 单条日志元素.

func NewLog

func NewLog(level common.Level, text string, args ...interface{}) Log

type OperatorManager

type OperatorManager interface {
	// GetExecutor
	// 执行器.
	GetExecutor() Executor

	// Push
	// 推送日志.
	Push(kv Kv, level common.Level, format string, args ...interface{})

	// SetExecutor
	// 设置执行器.
	SetExecutor(v Executor)
}

OperatorManager 日志操作接口.

var (
	// Operator
	// 日志操作.
	Operator OperatorManager
)

Directories

Path Synopsis
Package logger_file 输出到文件中, 例如: /var/logs/2023-03/2023-03-01.log.
Package logger_file 输出到文件中, 例如: /var/logs/2023-03/2023-03-01.log.
Package logger_term 打印到终端/控制台.
Package logger_term 打印到终端/控制台.

Jump to

Keyboard shortcuts

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