Documentation ¶
Index ¶
- func AppFatal(msg string, exit bool, exitCode int)
- func CoreLogger() *zap.Logger
- func DPanic(msg string, fields ...zap.Field)
- func Debug(msg string, fields ...zap.Field)
- func Enabled(level zapcore.Level) bool
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func Init(config *Config, opts ...zap.Option)
- func LoggerLevel() zapcore.Level
- func Panic(msg string, fields ...zap.Field)
- func Sync()
- func Warn(msg string, fields ...zap.Field)
- type Config
- type GeneralLogger
- type Level
- type Logger
- func (logger *Logger) DPanic(msg string, fields ...zap.Field)
- func (logger *Logger) Debug(msg string, fields ...zap.Field)
- func (logger *Logger) Enabled(level zapcore.Level) bool
- func (logger *Logger) Error(msg string, fields ...zap.Field)
- func (logger *Logger) Fatal(msg string, fields ...zap.Field)
- func (logger *Logger) Info(msg string, fields ...zap.Field)
- func (logger *Logger) LoggerLevel() zapcore.Level
- func (logger *Logger) Panic(msg string, fields ...zap.Field)
- func (logger *Logger) Sync()
- func (logger *Logger) Warn(msg string, fields ...zap.Field)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppFatal ¶
AppFatal
@Description: 记录应用致命错误 出现应用启动时报错、log没有正确配置或log没有完全启动时,使用log无法记录下报错日志,此时可以使用该函数进行记录 @param msg string 错误消息 @param exit bool 是否退出 @param exitCode int 退出码
func CoreLogger ¶
func DPanic ¶
DPanic
@Description: 记录 DPanicLevel 级别的日志消息. 如果日志系统处于development模式,该方法将触发panics(DPanic意味着"development panic"). 这主要用于捕捉可自恢复,但不应出现的错误. @param msg string @param fields ...zap.Field
func Debug ¶
Debug
@Description: 记录 DebugLevel 级别的日志消息. @param msg string @param fields ...zap.Field
func Error ¶
Error
@Description: 记录 ErrorLevel 级别的日志消息. @param msg string @param fields ...zap.Field
func Fatal ¶
Fatal
@Description: 记录 FatalLevel 级别的日志消息. 日志系统随后会调用os.Exit(1), 即使FatalLevel级别不可用 @param msg string @param fields ...zap.Field
func Init ¶
Init
@Description: 初始化默认日志系统,使用日志前需要先自行初始化 @param config *Config @param opts ...zap.Option
func LoggerLevel ¶
Types ¶
type Config ¶
type Config struct { AppName string // 应用名 AppId string // 应用编号 Development bool // 开发模式(该模式下会使用更容易阅读的日志形式,但性能也更差) LogLevel zapcore.Level // 记录日志级别 LogsDirectory string // 日志文件上层目录,一般该目录为默认目录的"AppName"下 LogsFilenamePattern string // 日志文件名样式 LogsMaxAge time.Duration // 日志文件保存最大时间 LogsRotationCount uint // 日志文件个数限制(与最大保存时间不同时生效) LogsRotationTime time.Duration // 日志文件分割周期 LogsRotationSize int64 // 日志文件分割大小(单位字节) ZapLogEncoder zapcore.Encoder // zap日志编码器 }
Config
@Description: 日志配置定义
func NewDevConfig ¶
NewDevConfig
@Description: 构建开发模式默认配置 @param appName string @param appId string @param logDir string @return *Config
type GeneralLogger ¶
type GeneralLogger interface { Print(args ...any) Printf(format string, args ...any) Debug(args ...any) Debugf(format string, args ...any) Info(args ...any) Infof(format string, args ...any) Warn(args ...any) Warnf(format string, args ...any) Error(args ...any) Errorf(format string, args ...any) Fatal(args ...any) Fatalf(format string, args ...any) Panic(args ...any) Panicf(format string, args ...any) }
func SugarLogger ¶
func SugarLogger() GeneralLogger
type Level ¶ added in v0.0.4
type Level int8
const ( DebugLevel Level = iota - 1 // InfoLevel is the default logging priority. InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. DPanicLevel // PanicLevel logs a message, then panics. PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel )
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger
@Description: 日志封装对象
func NewLogger ¶
NewLogger
@Description: 构建新的日志系统 @param config *Config @param opts ...zap.Option @return *Logger
func (*Logger) DPanic ¶
DPanic
@Description: 记录 DPanicLevel 级别的日志消息. 如果日志系统处于development模式,该方法将触发panics(DPanic意味着"development panic"). 这主要用于捕捉可自恢复,但不应出现的错误. @receiver wrapper *Logger @param msg string @param fields ...zap.Field
func (*Logger) Debug ¶
Debug
@Description: 记录 DebugLevel 级别的日志消息. @receiver wrapper *Logger @param msg string @param fields ...zap.Field
func (*Logger) Enabled ¶
Enabled
@Description: 判定是否是可输出的日志等级 @receiver wrapper *Logger @param level zapcore.Level 日志等级 @return bool
func (*Logger) Error ¶
Error
@Description: 记录 ErrorLevel 级别的日志消息. @receiver wrapper *Logger @param msg string @param fields ...zap.Field
func (*Logger) Fatal ¶
Fatal
@Description: 记录 FatalLevel 级别的日志消息. 日志系统随后会调用os.Exit(1), 即使FatalLevel级别不可用 @receiver wrapper *Logger @param msg string @param fields ...zap.Field
func (*Logger) Info ¶
Info
@Description: 记录 InfoLevel 级别的日志消息. @receiver wrapper *Logger @param msg string @param fields ...zap.Field
func (*Logger) LoggerLevel ¶
func (*Logger) Panic ¶
Panic
@Description: 记录 PanicLevel 级别的日志消息. 调用后,日志系统随即会panics,即使PanicLevel级别不可用. @receiver wrapper *Logger @param msg string @param fields ...zap.Field
Source Files ¶
Click to show internal directories.
Click to hide internal directories.