Logger
Gorm has a default logger implementation, it will print Slow SQL and happening errors by default
The logger accepts few options, you can customize it during initialization, for example:
newLogger := logger.New( |
Log Levels
GORM defined log levels: Silent, Error, Warn, Info
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{ |
Debug
Debug a single operation, change current operation’s log level to logger.Info
db.Debug().Where("name = ?", "jinzhu").First(&User{}) |
Customize Logger
Refer to GORM’s default logger for how to define your own one
The logger needs to implement the following interface, it accepts context, so you can use it for log tracing
type Interface interface { |