Documentation ¶
Index ¶
- Constants
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func InitZapLogger(config *Config, opts ...zap.Option) (*zapLogger, error)
- func NewLogger(configs ...configurer) (*zap.Logger, error)
- func NewSugaredLogger(configs ...configurer) (*zap.SugaredLogger, error)
- func NewZapLogger(configs ...configurer) (*zapLogger, error)
- func Panic(msg string, fields ...zap.Field)
- func Warn(msg string, fields ...zap.Field)
- func WithConsole() configurer
- func WithDisableCaller() configurer
- func WithDisableErrorVerbose() configurer
- func WithDisableStacktrace() configurer
- func WithDisableTimestamp() configurer
- func WithFile(path, name string, maxSize, maxAge, maxBackups int, compress bool) configurer
- func WithFormat(format string) configurer
- func WithLevel(lvl Level) configurer
- type Config
- type FileConfig
- type Level
Constants ¶
View Source
const ( FormatJson = "json" FormatConsole = "console" FormatText = "text" )
Variables ¶
This section is empty.
Functions ¶
func NewSugaredLogger ¶
func NewSugaredLogger(configs ...configurer) (*zap.SugaredLogger, error)
func NewZapLogger ¶
func NewZapLogger(configs ...configurer) (*zapLogger, error)
func WithConsole ¶
func WithConsole() configurer
func WithDisableCaller ¶
func WithDisableCaller() configurer
func WithDisableErrorVerbose ¶
func WithDisableErrorVerbose() configurer
func WithDisableStacktrace ¶
func WithDisableStacktrace() configurer
func WithDisableTimestamp ¶
func WithDisableTimestamp() configurer
func WithFormat ¶
func WithFormat(format string) configurer
Types ¶
type Config ¶
type Config struct { Lvl Level `toml:"level" json:"level"` OsStdout bool `toml:"os-stdout" json:"os-stdout"` File *FileConfig `toml:"file" json:"file"` Format string `toml:"format" json:"format"` DisableTimestamp bool `toml:"disable-timestamp" json:"disable-timestamp"` Development bool `toml:"development" json:"development"` DisableCaller bool `toml:"disable-caller" json:"disable-caller"` DisableStacktrace bool `toml:"disable-stacktrace" json:"disable-stacktrace"` DisableErrorVerbose bool `toml:"disable-error-verbose" json:"disable-error-verbose"` }
Config represents log configurations in toml/json.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
func (*Config) BuildZapEncoder ¶
func (*Config) BuildZapEncoderConfig ¶
func (c *Config) BuildZapEncoderConfig() zapcore.EncoderConfig
func (*Config) BuildZapOptions ¶
func (*Config) BuildZapWriteSyncer ¶
func (c *Config) BuildZapWriteSyncer() ([]zapcore.WriteSyncer, error)
type FileConfig ¶
type FileConfig struct { Path string `toml:"path" json:"path"` Name string `toml:"name" json:"name"` // Along with lumberjack: // https://github.com/natefinch/lumberjack/blob/v2.0/lumberjack.go MaxSize int `toml:"maxsize" json:"maxsize"` MaxAge int `toml:"maxage" json:"maxage"` MaxBackups int `toml:"maxbackups" json:"maxbackups"` Compress bool `toml:"compress" json:"compress"` }
FileConfig represents file to record log in toml/json.
func NewFileConfig ¶
func NewFileConfig(path, name string, maxSize, maxAge, maxBackups int, compress bool) *FileConfig
func (*FileConfig) BuildLogger ¶
func (f *FileConfig) BuildLogger() (*lumberjack.Logger, error)
Click to show internal directories.
Click to hide internal directories.