Documentation ¶
Index ¶
- Variables
- func Debug(moduleName string, fields ...zap.Field)
- func DebugJSON(moduleName, name string, value interface{})
- func DebugString(moduleName, name, msg string)
- func Dump(value interface{}, msg ...string)
- func Error(moduleName string, fields ...zap.Field)
- func ErrorJSON(moduleName, name string, value interface{})
- func ErrorString(moduleName, name, msg string)
- func Fatal(moduleName string, fields ...zap.Field)
- func FatalJSON(moduleName, name string, value interface{})
- func FatalString(moduleName, name, msg string)
- func Info(moduleName string, fields ...zap.Field)
- func InfoJSON(moduleName, name string, value interface{})
- func InfoString(moduleName, name, msg string)
- func InitLogger(filename string, maxSize, maxBackup, maxAge int, compress bool, logType string, ...)
- func LogIf(err error)
- func LogInfoIf(err error)
- func LogWarnIf(err error)
- func Warn(moduleName string, fields ...zap.Field)
- func WarnJSON(moduleName, name string, value interface{})
- func WarnString(moduleName, name, msg string)
- type GormLogger
- func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})
- func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})
- func (l GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l GormLogger) Warn(ctx context.Context, str string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
View Source
var Logger *zap.Logger
Logger 全局 Logger 对象
Functions ¶
func DebugJSON ¶
func DebugJSON(moduleName, name string, value interface{})
DebugJSON 记录对象类型的 debug 日志,使用 json.Marshal 进行编码。调用示例: logger.DebugJSON("Auth", "读取登录用户", auth.CurrentUser())
func DebugString ¶
func DebugString(moduleName, name, msg string)
DebugString 记录一条字符串类型的 debug 日志,调用示例:
func ErrorString ¶
func ErrorString(moduleName, name, msg string)
func Fatal ¶
Fatal 级别同 Error(), 写完 log 后调用 os.Exit(1) 退出程序 logger.DebugString("SMS", "短信内容", string(result.RawResponse))
func FatalString ¶
func FatalString(moduleName, name, msg string)
func InfoString ¶
func InfoString(moduleName, name, msg string)
func InitLogger ¶
func InitLogger(filename string, maxSize, maxBackup, maxAge int, compress bool, logType string, level string)
InitLogger 日志初始化
func WarnString ¶
func WarnString(moduleName, name, msg string)
Types ¶
type GormLogger ¶
GormLogger 操作对象,实现 gormlogger.Interface
func NewGormLogger ¶
func NewGormLogger() GormLogger
NewGormLogger 外部调用。实例化一个 GormLogger 对象,示例:
DB, err := gorm.Open(dbConfig, &gorm.Config{ Logger: logger.NewGormLogger(), })
func (GormLogger) Error ¶
func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})
Error 实现 gormlogger.Interface 的 Error 方法
func (GormLogger) Info ¶
func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})
Info 实现 gormlogger.Interface 的 Info 方法
func (GormLogger) LogMode ¶
func (l GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
LogMode 实现 gormlogger.Interface 的 LogMode 方法
Click to show internal directories.
Click to hide internal directories.