Gorm: Turn off callback registration logging

Created on 16 Jan 2020  路  6Comments  路  Source: go-gorm/gorm

The gorm update from v1.9.11 to v1.9.12 has led to all callback registrations getting logged like:

[info] registering callback `dd-trace-go:before_create` from /Users/nilswerner/Code/Golang/service/app/services/persistence/postgres/utilities.go:32

I can't turn it off using db.LogMode(false) and I feel like it should be off by default.

I'm on: github.com/jinzhu/gorm v1.9.12

gorm_v1

Most helpful comment

I implemented a work-around on our end which consists in re-declaring the nopLogger and setting it as the default one.

type nopLogger struct{}

func (nopLogger) Print(values ...interface{}) {}

// ...

db.LogMode(false)
db.SetLogger(nopLogger{}) // Preventing callback logs from being displayed

All 6 comments

Getting the same issue here. The log mode is ignored by the callback logger, but it shouldn't be.

Likewise

I implemented a work-around on our end which consists in re-declaring the nopLogger and setting it as the default one.

type nopLogger struct{}

func (nopLogger) Print(values ...interface{}) {}

// ...

db.LogMode(false)
db.SetLogger(nopLogger{}) // Preventing callback logs from being displayed

This issue will be automatically closed because it is marked as GORM V1 issue, we have released the public testing GORM V2 release and its documents https://v2.gorm.io/docs/ already, the testing release has been used in some production services for a while, and going to release the final version in following weeks, we are still actively collecting feedback before it, please open a new issue for any suggestion or problem, thank you

Also check out https://github.com/go-gorm/gorm/wiki/GORM-V2-Release-Note-Draft for how to use the public testing version and its changelog

This issue will be automatically closed because it is marked as GORM V1 issue, we have released the public testing GORM V2 release and its documents https://v2.gorm.io/docs/ already, the testing release has been used in some production services for a while, and going to release the final version in following weeks, we are still actively collecting feedback before it, please open a new issue for any suggestion or problem, thank you

Also check out https://github.com/go-gorm/gorm/wiki/GORM-V2-Release-Note-Draft for how to use the public testing version and its changelog

Is this fixed in v2?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

littletwolee picture littletwolee  路  3Comments

alanyuen picture alanyuen  路  3Comments

leebrooks0 picture leebrooks0  路  3Comments

hypertornado picture hypertornado  路  3Comments

Quentin-M picture Quentin-M  路  3Comments