logger

package module
v0.0.0-...-8a015c9 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 10 Imported by: 0

README

logger

golang zap 日志库封装


特性

  • 支持多种日志writer,console、file,file_rotate,自定义
  • 支持不同错误级别输出配置
  • 支持控制台颜色输出/仅控制台颜色输出

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...*Option) (*zap.Logger, error)

New 返回zap.Logger

Types

type Option

type Option struct {
	Output         []*Output `mapstructure:"output" json:"output" yaml:"output"`
	Name           string    `json:"name" yaml:"name"`
	ShowLine       bool      `json:"showLine" yaml:"showLine"`
	ShowStacktrace bool      `json:"ShowStacktrace" yaml:"ShowStacktrace"`
	// 公共配置
	Level string `json:"level" yaml:"level"`
	// Color         bool   `json:"color" yaml:"color"`
	Format        string `json:"format" yaml:"format"`
	MessageKey    string `json:"messageKey" yaml:"messageKey"`
	LevelKey      string `json:"levelKey" yaml:"levelKey"`
	TimeKey       string `json:"timeKey" yaml:"timeKey"`
	NameKey       string `json:"nameKey" yaml:"nameKey"`
	CallerKey     string `json:"callerKey" yaml:"callerKey"`
	FunctionKey   string `json:"functionKey" yaml:"functionKey"`
	StacktraceKey string `json:"stacktraceKey" yaml:"stacktraceKey"`
	LineEnding    string `json:"lineEnding" yaml:"lineEnding"`
	LevelEncoder  string `json:"levelEncoder" yaml:"levelEncoder"` // capital,capitalColor, lower(default), lowerColor
	TimeFormat    string `json:"timeFormat" yaml:"timeFormat"`
}

type Output

type Output struct {
	Writer        string                 `json:"writer" yaml:"writer"`
	Level         string                 `json:"level" yaml:"level"`
	Format        string                 `json:"format" yaml:"format"`
	MessageKey    string                 `json:"messageKey" yaml:"messageKey"`
	LevelKey      string                 `json:"levelKey" yaml:"levelKey"`
	TimeKey       string                 `json:"timeKey" yaml:"timeKey"`
	NameKey       string                 `json:"nameKey" yaml:"nameKey"`
	CallerKey     string                 `json:"callerKey" yaml:"callerKey"`
	FunctionKey   string                 `json:"functionKey" yaml:"functionKey"`
	StacktraceKey string                 `json:"stacktraceKey" yaml:"stacktraceKey"`
	LineEnding    string                 `json:"lineEnding" yaml:"lineEnding"`
	LevelEncoder  string                 `json:"levelEncoder" yaml:"levelEncoder"` // capital, capitalColor, color, lower(default)
	TimeFormat    string                 `json:"timeFormat" yaml:"timeFormat"`
	Option        map[string]interface{} `json:"option" yaml:"option"`
}

type Writer

type Writer func(option map[string]interface{}) (zapcore.WriteSyncer, error)

Jump to

Keyboard shortcuts

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