Documentation ¶
Overview ¶
Package logger 处理日志相关逻辑
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 gl.LogLevel) gl.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 Once sync.Once )
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 日志,调用示例:
logger.DebugString("SMS", "短信内容", string(result.RawResponse))
func Dump ¶
func Dump(value interface{}, msg ...string)
Dump 调试专用,不会中断程序,会在终端打印出 warning 消息。 第一个参数会使用 json.Marshal 进行渲染,第二个参数消息(可选)
logger.Dump(user.User{Name:"test"}) logger.Dump(user.User{Name:"test"}, "用户信息")
func ErrorString ¶
func ErrorString(moduleName, name, msg string)
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 ¶
Click to show internal directories.
Click to hide internal directories.