Skip to content

Commit

Permalink
chore: add personalized logger
Browse files Browse the repository at this point in the history
  • Loading branch information
kocierik committed Feb 24, 2024
1 parent 8bd7b17 commit 89c7f2d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions util/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// logger_util.go

package util

import (
"gorm.io/gorm/logger"
"log"
"os"
"time"
)

func NewGormLogger() logger.Interface {
return logger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer
logger.Config{
SlowThreshold: time.Second, // Slow SQL threshold
LogLevel: logger.Silent, // Log level
IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger
ParameterizedQueries: true, // Don't include params in the SQL log
Colorful: false, // Disable color
},
)
}

0 comments on commit 89c7f2d

Please sign in to comment.