This commit is contained in:
parent
5df6ccefe2
commit
073bcc4a1d
@ -12,8 +12,10 @@ import (
|
|||||||
"gorm.io/driver/mysql"
|
"gorm.io/driver/mysql"
|
||||||
"gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
gl "gorm.io/gorm/logger"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
"wireguard-dashboard/client"
|
"wireguard-dashboard/client"
|
||||||
"wireguard-dashboard/config"
|
"wireguard-dashboard/config"
|
||||||
)
|
)
|
||||||
@ -69,8 +71,18 @@ func initDatabase() {
|
|||||||
dbDialector = sqlite.Open(config.Config.Database.GetDSN())
|
dbDialector = sqlite.Open(config.Config.Database.GetDSN())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logLevel := gl.Info
|
||||||
|
if os.Getenv("GIN_MODE") == "release" {
|
||||||
|
logLevel = gl.Error
|
||||||
|
}
|
||||||
|
|
||||||
db, err := gorm.Open(dbDialector, &gorm.Config{
|
db, err := gorm.Open(dbDialector, &gorm.Config{
|
||||||
Logger: logger.DefaultGormLogger(),
|
Logger: logger.NewGormLoggerWithConfig(gl.Config{
|
||||||
|
SlowThreshold: time.Second, // Slow SQL threshold
|
||||||
|
IgnoreRecordNotFoundError: false, // 忽略没找到结果的错误
|
||||||
|
LogLevel: logLevel, // Log level
|
||||||
|
Colorful: false, // Disable color
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user