Logging queries

    Then add the provided query hook which by default only prints failed queries:

    1. import "github.com/uptrace/bun/extra/bundebug"
    2. db := bun.NewDB(sqldb, dialect)

    You can also disable the hook by default and use environment variables to enable it when needed:

    1. // disable the hook
    2. bundebug.WithEnabled(false),
    3. // BUNDEBUG=1 logs failed queries
    4. )

    Logrus hook

    Use QueryHookOptions to adjust log levels and behavior:

    1. db := bun.NewDB(sqldb, dialect)
    2. log := logrus.New()