writer

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// FieldKeyTraceID is the field key for the trace ID.
	FieldKeyTraceID = "trace.id"

	// FieldKeyTransactionID is the field key for the transaction ID.
	FieldKeyTransactionID = "transaction.id"

	// FieldKeySpanID is the field key for the span ID.
	FieldKeySpanID = "span.id"
)

Variables

This section is empty.

Functions

func GetLoggerLevel

func GetLoggerLevel(lvl string) zapcore.Level

func GetLowLogLevel

func GetLowLogLevel(writers []Writer) zapcore.Level

GetLowLogLevel 获取writer中最低日志级别

Types

type ApmConfig

type ApmConfig struct {
	CheckFunc func(*ZEntry) bool
}

ApmConfig 用户自定义apm配置

type ConsoleConfig

type ConsoleConfig struct {
	LogLevel  string             // 日志级别,可选,默认debug
	CheckFunc func(*ZEntry) bool // 日志检查函数,可选参数
}

ConsoleConfig 用户自定义console配置

type FileConfig

type FileConfig struct {
	Filename    string             // 日志文件, 默认"./log/zlog.log",可选
	MaxFileSize int                // 日志文件单个文件最大大小,单位为MB,默认100,可选
	MaxBackups  int                // 日志文件最大历史保留份数,默认5,可选
	MaxAge      int                // 日志文件最长存活时间,单位为天, 默认30,可选
	Compress    bool               // 历史日志压缩保存,默认false,可选
	LogLevel    string             // 日志级别,默认debug,可选
	CheckFunc   func(*ZEntry) bool // 日志检查,可选参数
}

FileConfig 用户自定义File配置

type SentryConfig

type SentryConfig struct {
	DSN              string             // DSN地址,必填
	AttachStacktrace bool               // 是否追加堆栈信息,默认否,可选
	ServerName       string             // 服务名, 可选
	LogLevel         string             // 写入Sentry的日志级别,默认info级别,可选
	CheckFunc        func(*ZEntry) bool // 日志检查,可选参数
}

用户自定义sentry配置

type Writer

type Writer interface {
	// GetLogLevel 获取日志级别
	GetLogLevel() string
	// Check 日志检查,过滤掉不必要的日志输入
	Check(*ZEntry) bool
	// Write 日志输出内容
	Write(message string, attr map[string]interface{}) error
}

func NewApmWriter

func NewApmWriter(opt *ApmConfig) Writer

func NewConsoleWriter

func NewConsoleWriter(opt *ConsoleConfig) Writer

func NewFileWriter

func NewFileWriter(opt *FileConfig) Writer

func NewSentryWriter

func NewSentryWriter(opt *SentryConfig) Writer

type ZEntry

type ZEntry struct {
	Loglevel string // 日志级别
	Message  string // 日志内容
}

ZEntry 日志内容

Jump to

Keyboard shortcuts

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