logger

package
v0.0.0-...-0ab0872 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(template string, fields ...zap.Field)

固定类型,速度更快,打印日志尽量用这种

func Debugf

func Debugf(template string, args ...interface{})

可变参数,速度慢

func Error

func Error(template string, fields ...zap.Field)

func Errorf

func Errorf(template string, args ...interface{})

func Fatal

func Fatal(template string, fields ...zap.Field)

func Fatalf

func Fatalf(template string, args ...interface{})

func Info

func Info(template string, fields ...zap.Field)

func Infof

func Infof(template string, args ...interface{})

func Init

func Init(cfg *Config)

func InitDefault

func InitDefault(env string)

for test, if env is "", use dev model

func New

func New(cfg *Config) (*zap.Logger, error)

if cfg is nil, use default config

func Panic

func Panic(template string, fields ...zap.Field)

func Panicf

func Panicf(template string, args ...interface{})

func Warn

func Warn(template string, fields ...zap.Field)

func Warnf

func Warnf(template string, args ...interface{})

Types

type Config

type Config struct {
	Level      string `yaml:"level" json:"level" default:"info"`
	Encoding   string `yaml:"encoding" json:"encoding" default:"console"`
	EncodeTime string `yaml:"encode_time" json:"encode_time" default:"2006-01-02T15:04:05.000Z0700"`
	UseStdout  bool   `yaml:"use_stdout" json:"use_stdout" default:"true"`
	Filename   string `yaml:"filename" json:"filename" default:"./logs/service.clog"`
	MaxAge     int    `yaml:"max_age" json:"max_age" default:"15"`    // days
	MaxSize    int    `yaml:"max_size" json:"max_size" default:"500"` // MB
	MaxBackups int    `yaml:"max_backups" json:"max_backups" default:"15"`
	Compress   bool   `yaml:"compress" json:"compress" default:"true"`
}

Jump to

Keyboard shortcuts

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