@@ -165,11 +165,11 @@ func (db *Database) Initialize() {
|
||||
}
|
||||
|
||||
dbConnString := fmt.Sprintf("postgres://%s@%s:%s/%s?connect_timeout=10&fallback_application_name=fastpastebin&sslmode=disable", userpass, c.Config.Database.Address, c.Config.Database.Port, c.Config.Database.Database)
|
||||
c.Logger.Debug().Msgf("Database connection string: %s", dbConnString)
|
||||
c.Logger.Debug().Str("DSN", dbConnString).Msg("Database connection string composed")
|
||||
|
||||
dbConn, err := sqlx.Connect("postgres", dbConnString)
|
||||
if err != nil {
|
||||
c.Logger.Error().Msgf("Failed to connect to database: %s", err.Error())
|
||||
c.Logger.Error().Err(err).Msg("Failed to connect to database")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ func (db *Database) Shutdown() {
|
||||
if db.db != nil {
|
||||
err := db.db.Close()
|
||||
if err != nil {
|
||||
c.Logger.Error().Msgf("Failed to close database connection: %s", err.Error())
|
||||
c.Logger.Error().Err(err).Msg("Failed to close database connection")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user