- Add function RenderNamedTemplate executes a named template from the registered set with the given data and returns the rendered HTML.
- gormlogger.Silent is the log level that suppresses all Gorm log messages, including the "record not found" warnings.
This commit is contained in:
parent
59eadf29d0
commit
19dba8f504
2 changed files with 32 additions and 4 deletions
16
core.go
16
core.go
|
|
@ -26,6 +26,7 @@ import (
|
|||
"gorm.io/driver/postgres"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
gormlogger "gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
var loggr *logger.Logger
|
||||
|
|
@ -517,13 +518,18 @@ func NewGorm() *gorm.DB {
|
|||
if err != nil {
|
||||
panic(fmt.Sprintf("error locating sqlite file: %v", err.Error()))
|
||||
}
|
||||
db, err = gorm.Open(sqlite.Open(fullSqlitePath), &gorm.Config{})
|
||||
db, err = gorm.Open(sqlite.Open(fullSqlitePath), &gorm.Config{
|
||||
Logger: gormlogger.Default.LogMode(gormlogger.Silent),
|
||||
})
|
||||
default:
|
||||
panic("database driver not selected")
|
||||
}
|
||||
if gormC.EnableGorm && err != nil {
|
||||
panic(fmt.Sprintf("gorm has problem connecting to %v, (if it's not needed you can disable it in config/gorm.go): %v", os.Getenv("DB_DRIVER"), err))
|
||||
}
|
||||
if db != nil {
|
||||
db.Logger = db.Logger.LogMode(gormlogger.Silent)
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
|
|
@ -560,7 +566,9 @@ func postgresConnect() (*gorm.DB, error) {
|
|||
os.Getenv("POSTGRES_SSL_MODE"),
|
||||
os.Getenv("POSTGRES_TIMEZONE"),
|
||||
)
|
||||
return gorm.Open(postgres.Open(dsn), &gorm.Config{})
|
||||
return gorm.Open(postgres.Open(dsn), &gorm.Config{
|
||||
Logger: gormlogger.Default.LogMode(gormlogger.Silent),
|
||||
})
|
||||
}
|
||||
|
||||
// mysqlConnect establishes a connection to a MySQL database using credentials and configurations from environment variables.
|
||||
|
|
@ -581,7 +589,9 @@ func mysqlConnect() (*gorm.DB, error) {
|
|||
DontSupportRenameIndex: true, // drop & create when rename index, rename index not supported before MySQL 5.7, MariaDB
|
||||
DontSupportRenameColumn: true, // `change` when rename column, rename column not supported before MySQL 8, MariaDB
|
||||
SkipInitializeWithVersion: false, // auto configure based on currently MySQL version
|
||||
}), &gorm.Config{})
|
||||
}), &gorm.Config{
|
||||
Logger: gormlogger.Default.LogMode(gormlogger.Silent),
|
||||
})
|
||||
}
|
||||
|
||||
// getJWT returns a function that initializes and provides a *JWT instance configured with environment variables.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue