Documentation ¶
Index ¶
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func GetLevel() zapcore.Level
- func GetLogger() *zap.Logger
- func GetSurgar() *zap.SugaredLogger
- func Info(msg string, fields ...zap.Field)
- func New(cfg *Config)
- func Panic(msg string, fields ...zap.Field)
- func Reset(logger *zap.Logger, props *ZapProperties)
- func SetLevel(l zapcore.Level)
- func Sync() error
- func Warn(msg string, fields ...zap.Field)
- func With(fields ...zap.Field) *zap.Logger
- type Config
- type FileLogConfig
- type ZapProperties
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func Error ¶
Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func Fatal ¶
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func GetSurgar ¶
func GetSurgar() *zap.SugaredLogger
func Info ¶
Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func Panic ¶
Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then panics, even if logging at PanicLevel is disabled.
Types ¶
type Config ¶
type Config struct { // Log level. Level string `toml:"level" json:"level"` // Log format. one of json, text, or console. Format string `toml:"format" json:"format"` // File log config. File FileLogConfig `toml:"file" json:"file"` }
Config serializes log related config in toml/json.
type FileLogConfig ¶
type FileLogConfig struct { FileDir string `toml:"filedir" json:"filedir"` // Log filename, leave empty to disable file log. Filename string `toml:"filename" json:"filename"` // Max size for a single file, in MB. MaxSize int `toml:"max-size" json:"max-size"` // Max log keep days, default is never deleting. MaxDays int `toml:"max-days" json:"max-days"` // Maximum number of old log files to retain. MaxBackups int `toml:"max-backups" json:"max-backups"` Compress bool `toml:"compress" json:"compress"` }
FileLogConfig serializes file log related config in toml/json.
type ZapProperties ¶
type ZapProperties struct { Core zapcore.Core Syncer zapcore.WriteSyncer Level zap.AtomicLevel }
func InitLogger ¶
InitLogger initializes a zap logger.
func InitLoggerWithWriteSyncer ¶
func InitLoggerWithWriteSyncer(cfg *Config, output zapcore.WriteSyncer, opts ...zap.Option) (*zap.Logger, *ZapProperties, error)
InitLoggerWithWriteSyncer initializes a zap logger with specified write syncer.