xlog

package
v0.0.0-...-bb138a7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFormatter

func AddFormatter(name string, f Formatter)

AddFormatter Add custom log formatting processor

func AddWriter

func AddWriter(name string, w Writer)

AddWriter Add custom log writing driver

func Default

func Default() *zap.Logger

func New

func New(config Config) *zap.Logger

New 返回日志实例

func NewE

func NewE(config Config) (*zap.Logger, error)

NewE 实例化日志

func RemoveFormatter

func RemoveFormatter(names ...string)

RemoveFormatter Remove custom log formatting processor

func RemoveWriter

func RemoveWriter(names ...string)

RemoveWriter Remove custom log writing driver

Types

type Config

type Config struct {
	Name         string                 `json:"name"`                           // Name 日志名称
	Output       []string               `json:"output"`                         // Output 输出渠道
	Level        string                 `json:"level"`                          // Level 日志记录级别
	Trace        bool                   `json:"trace"`                          // Trace 是否显示调用
	Format       string                 `json:"format"`                         // Format 日志格式化方式
	Encoder      Encoder                `json:"encoder" mapstructure:"encoder"` // Encoder 日志显示格式化配置
	LevelEncoder string                 `json:"levelEncoder"`                   // LevelEncoder 日志级别格式化处理 支持: capital, capitalColor, color, lower(default)
	TimeFormat   string                 `json:"timeFormat"`                     // TimeFormat 时间格式化
	Channels     map[string]interface{} `json:"channels"`                       // Channels 日志输出渠道配置
}

Config Log configuration

type Encoder

type Encoder struct {
	Name       string `json:"name"`       // Name 日志名称key
	Time       string `json:"time"`       // Time 日志时间key
	Level      string `json:"level"`      // Level 日志level key
	Caller     string `json:"caller"`     // Caller 日志调用位置key
	Message    string `json:"message"`    // Message 日志内容key
	Function   string `json:"function"`   // Function 日志调用函数key
	Stacktrace string `json:"stacktrace"` // Stacktrace 日志调用 trace key
	LineEnding string `json:"lineEnding"` // LineEnding 日志行尾结束符
}

Encoder Log content formatting configuration

type Formatter

type Formatter func(cfg zapcore.EncoderConfig) zapcore.Encoder

Formatter Log formatting processor

type Writer

type Writer func(option interface{}) (zapcore.WriteSyncer, error)

Writer Log Writer interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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