Skip to content

Commit

Permalink
refactor: logging and add conditional checks
Browse files Browse the repository at this point in the history
fix #74

- Refactor type assertion and conditional logging into a more concise format in `zap.go`
- Add conditional logging based on `DefaultLevel` being `InfoLevel` in `zap.go`

Signed-off-by: Bo-Yi Wu <[email protected]>
  • Loading branch information
appleboy committed May 3, 2024
1 parent 78ab44e commit e3d6f72
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ func GinzapWithConfig(logger ZapLogger, conf *Config) gin.HandlerFunc {
logger.Error(e, fields...)
}
} else {
zl, ok := logger.(*zap.Logger)
if ok {
if zl, ok := logger.(*zap.Logger); ok {
zl.Log(conf.DefaultLevel, "", fields...)
} else if conf.DefaultLevel == zapcore.InfoLevel {
logger.Info(path, fields...)
} else {
logger.Error(path, fields...)
}
Expand Down

0 comments on commit e3d6f72

Please sign in to comment.