Documentation
¶
Index ¶
- func CloseAll() error
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func DefaultZapLogger() *zap.Logger
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func InitDefaultLogger(config LogConfig) error
- func NewDefaultLogger(level, logFile, consoleFormat string) error
- func Sync() error
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type LogConfig
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(template string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(template string, args ...interface{})
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(template string, args ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(template string, args ...interface{})
- func (l *Logger) SugaredLogger() *zap.SugaredLogger
- func (l *Logger) Sync() error
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(template string, args ...interface{})
- func (l *Logger) ZapLogger() *zap.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultZapLogger ¶ added in v0.0.3
DefaultZapLogger returns the configured default logger for structured zap consumers.
func InitDefaultLogger ¶
InitDefaultLogger 旧版本初始化函数,兼容老代码
func NewDefaultLogger ¶
NewDefaultLogger 旧版本初始化函数,兼容老代码
Types ¶
type LogConfig ¶
type LogConfig struct {
// ConsoleLevel is the minimum log level for console output: debug, info, warn, error.
// Empty string defaults to "info".
ConsoleLevel string `yaml:"console_level"`
// FileLevel is the minimum log level for file output: debug, info, warn, error.
// Empty string defaults to "debug".
FileLevel string `yaml:"file_level"`
// ConsoleFormat is the console (stdout) output format.
// "" - fallback to default mask "LCM"
// "text" - console text format (zap console; structured fields appended as a JSON object)
// "json" - json format
// "off" - disable console output
// any other - mask format, e.g. "TLCM", "LM" (T=time L=level C=caller M=message)
ConsoleFormat string `yaml:"console_format"`
// LogFileFormat is the file output format (same value options as ConsoleFormat).
// "" - fallback to default "json"
// "text" - console text format
// "json" - json format
// "off" - disable file output
// any other - mask format
LogFileFormat string `yaml:"log_file_format"`
// LogFilePath is the log file path; empty means no file output.
LogFilePath string `yaml:"log_file_path"`
// MaxSize is the maximum size in megabytes of a single log file before rotation.
MaxSize int `yaml:"max_size"`
// MaxBackups is the maximum number of old log files to retain.
MaxBackups int `yaml:"max_backups"`
// MaxAge is the maximum number of days to retain old log files.
MaxAge int `yaml:"max_age"`
// Compress determines whether rotated files are compressed.
Compress bool `yaml:"compress"`
}
LogConfig holds logging configuration.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger 日志器实例,线程安全
func CreateLogger ¶
CreateLogger 创建新的日志器
func DefaultLogger ¶ added in v0.0.3
func DefaultLogger() *Logger
DefaultLogger returns the default *Logger instance for use with interface types.
func (*Logger) SugaredLogger ¶ added in v0.0.3
func (l *Logger) SugaredLogger() *zap.SugaredLogger
SugaredLogger returns the underlying zap.SugaredLogger for libraries that use the sugared API.
Click to show internal directories.
Click to hide internal directories.