Skip to content

Commit

Permalink
feat(gorm): Added LoggerAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
flc1125 committed Nov 7, 2023
1 parent 99f20c2 commit 5008c78
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gorm/adapter/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ func (l *loggerAdapter) LogMode(level logger.LogLevel) logger.Interface {

func (l *loggerAdapter) Info(ctx context.Context, s string, i ...interface{}) {
if l.LogLevel >= logger.Info {
_ = l.Log(log.LevelInfo, fmt.Sprintf(l.infoStr+s, i...))
_ = l.Log(log.LevelInfo, fmt.Sprintf(l.infoStr+s, append([]interface{}{utils.FileWithLineNum()}, i...)...))
}
}

func (l *loggerAdapter) Warn(ctx context.Context, s string, i ...interface{}) {
if l.LogLevel >= logger.Warn {
_ = l.Log(log.LevelWarn, fmt.Sprintf(l.warnStr+s, i...))
_ = l.Log(log.LevelWarn, fmt.Sprintf(l.warnStr+s, append([]interface{}{utils.FileWithLineNum()}, i...)...))
}
}

func (l *loggerAdapter) Error(ctx context.Context, s string, i ...interface{}) {
if l.LogLevel >= logger.Error {
_ = l.Log(log.LevelError, fmt.Sprintf(l.errStr+s, i...))
_ = l.Log(log.LevelError, fmt.Sprintf(l.errStr+s, append([]interface{}{utils.FileWithLineNum()}, i...)...))
}
}

Expand Down

0 comments on commit 5008c78

Please sign in to comment.