loggerx

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLevel the default log level
	DefaultLevel = zapcore.InfoLevel

	// DefaultTimeLayout the default time layout;
	DefaultTimeLayout = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func CreateSpecialLogger

func CreateSpecialLogger() *zap.Logger

func Default

func Default() *zap.Logger

func New

func New(logInfo *LoggersInfo) (*zap.Logger, error)

func NewJSONLogger

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

NewJSONLogger 使用json日志

func SetDefault

func SetDefault(logger *zap.Logger)

func WrapMeta

func WrapMeta(err error, metas ...Meta) (fields []zap.Field)

WrapMeta 用来包装zap.Field

Types

type LoggersInfo

type LoggersInfo struct {
	// loggers.Level日志级别
	Level string `toml:"Level" json:"Level"`
	// loggers.File 项目日志存放文件
	File string `toml:"File" json:"File"`
	// loggers.ErrFile 项目错误日志存放文件
	ErrFile string `toml:"ErrFile" json:"ErrFile"`
	// 时间风格
	TimeLayout string `toml:"TimeLayout" json:"TimeLayout"`
	// MaxSize  单个文件最大尺寸,默认单位 M
	MaxSize int `toml:"MaxSize" json:"MaxSize"`
	// MaxBackups 最多保留 多少个备份
	MaxBackup int `toml:"MaxBackup" json:"MaxBackup"`
	// MaxAge 备份的最大天数
	MaxAge int `toml:"MaxAge" json:"MaxAge"`
	// 是否开启终端日志
	DisableConsole bool `toml:"DisableConsole" json:"DisableConsole"`
	// contains filtered or unexported fields
}

func (*LoggersInfo) GetDomain

func (l *LoggersInfo) GetDomain() string

func (*LoggersInfo) SetDomain

func (l *LoggersInfo) SetDomain(domain string)

type Meta

type Meta interface {
	Key() string
	Value() interface{}
	// contains filtered or unexported methods
}

Meta 一个包装zip.Field的键值对

func NewMeta

func NewMeta(key string, value interface{}) Meta

NewMeta create meat

type Option

type Option func(*option)

Option custom setup config

func WithConsole

func WithConsole(disable bool) Option

WithConsole 关闭终端日志, 即日志不再向 os.Stdout 和 os.Stderr 输出

func WithErrorFile

func WithErrorFile(errFile string, maxSize int, maxBackups int, maxAge int) Option

WithErrorFile 独立的error日志.

func WithField

func WithField(key, value string) Option

WithField 添加一些公共字段到日志.

func WithLevel

func WithLevel(level string) Option

WithLevel 设置日志级别.

func WithLogFile

func WithLogFile(file string, maxSize int, maxBackups int, maxAge int) Option

WithLogFile 使用日志文件切割.

func WithTimeLayout

func WithTimeLayout(timeLayout string) Option

WithTimeLayout 时间格式化风格

Jump to

Keyboard shortcuts

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