Documentation ¶
Index ¶
- Constants
- func CreateSpecialLogger() *zap.Logger
- func Default() *zap.Logger
- func New(logInfo *LoggersInfo) (*zap.Logger, error)
- func NewJSONLogger(opts ...Option) (*zap.Logger, error)
- func SetDefault(logger *zap.Logger)
- func WrapMeta(err error, metas ...Meta) (fields []zap.Field)
- type LoggersInfo
- type Meta
- type Option
- func WithConsole(disable bool) Option
- func WithErrorFile(errFile string, maxSize int, maxBackups int, maxAge int) Option
- func WithField(key, value string) Option
- func WithLevel(level string) Option
- func WithLogFile(file string, maxSize int, maxBackups int, maxAge int) Option
- func WithTimeLayout(timeLayout string) Option
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 SetDefault ¶
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的键值对
type Option ¶
type Option func(*option)
Option custom setup config
func WithConsole ¶
WithConsole 关闭终端日志, 即日志不再向 os.Stdout 和 os.Stderr 输出
func WithErrorFile ¶
WithErrorFile 独立的error日志.
func WithLogFile ¶
WithLogFile 使用日志文件切割.
Click to show internal directories.
Click to hide internal directories.