Documentation
¶
Index ¶
- func AppFileErrorLog(format string, a ...interface{}) error
- func Debugf(format string, args ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalw(msg string, keysAndValues ...interface{})
- func HookSystemLog(args map[string]string) zap.Option
- func Infof(format string, args ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func Logger() *zap.Logger
- func NewLogger(cfg Config) *zap.Logger
- func Panicf(format string, args ...interface{})
- func SetLogger(l *zap.Logger)
- func SetupLogger(cfg Config)
- func Sugared() *zap.SugaredLogger
- func Warnf(format string, args ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- func WriteFileLog(filename, format string, a ...interface{}) error
- type Config
- type Hooker
- type SyslogHook
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppFileErrorLog ¶
func SetupLogger ¶ added in v0.3.3
func SetupLogger(cfg Config)
func Sugared ¶ added in v0.2.3
func Sugared() *zap.SugaredLogger
func WriteFileLog ¶
Types ¶
type Config ¶
type Config struct {
// Level is the minimum enabled logging level. Note that this is a dynamic
// level, so calling Config.Level.SetLevel will atomically change the log
// level of all loggers descended from this config.
Level string `json:"level" yaml:"level"`
// Development puts the logger in development mode, which changes the
// behavior of DPanicLevel and takes stacktraces more liberally.
Development bool `json:"development" yaml:"development"`
// Encoding sets the logger's encoding. Valid values are "json" and "console"
Encoding string `json:"encoding" yaml:"encoding"`
// Filename is the file to write logs to. Backup log files will be retained
// in the same directory. It uses <processname>-lumberjack.log in
// os.TempDir() if empty.
Filename string `json:"filename" yaml:"filename"`
// ErrorFilename is the file to write error logs to. Backup log files will be retained
// in the same directory.
ErrorFilename string `json:"error_filename" yaml:"error_filename"`
// MaxSize is the maximum size in megabytes of the log file before it gets
// rotated. It defaults to 100 megabytes.
MaxSize int `json:"max_size" yaml:"max_size"`
// MaxAge is the maximum number of days to retain old log files based on the
// timestamp encoded in their filename. Note that a day is defined as 24
// hours and may not exactly correspond to calendar days due to daylight
// savings, leap seconds, etc. The default is not to remove old log files
// based on age.
MaxAge int `json:"max_age" yaml:"max_age"`
// MaxBackups is the maximum number of old log files to retain. The default
// is to retain all old log files (though MaxAge may still cause them to get
// deleted.)
MaxBackups int `json:"max_backups" yaml:"max_backups"`
// LocalTime determines if the time used for formatting the timestamps in
// backup files is the computer's local time. The default is to use UTC
// time.
LocalTime bool `json:"localtime" yaml:"localtime"`
// Compress determines if the rotated log files should be compressed
// using gzip. The default is not to perform compression.
Compress bool `json:"compress" yaml:"compress"`
}
配置参数
func (*Config) CreateEncoder ¶ added in v0.3.3
func (*Config) CreateLogCore ¶ added in v0.3.3
func (*Config) CreateLogWriter ¶ added in v0.3.3
type SyslogHook ¶
type SyslogHook struct {
// contains filtered or unexported fields
}
SyslogHook to send logs via syslog.
func (*SyslogHook) Name ¶
func (h *SyslogHook) Name() string
Click to show internal directories.
Click to hide internal directories.