Skip to content

Commit

Permalink
fix: log more details when setting up DB connection (#443)
Browse files Browse the repository at this point in the history
We recently had to debug a situation where setting up the DB connection
failed. We found this difficult because the logs were quite sparse in
what they recorded. This change adds username and TLS string to the log,
both of which should not contain secrets.
  • Loading branch information
blgm authored Mar 29, 2022
1 parent ed8391e commit 691f206
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions db_service/setup_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ func setupMysqlDb(logger lager.Logger) (*gorm.DB, error) {
}

logger.Info("Connecting to MySQL Database", lager.Data{
"host": dbHost,
"port": dbPort,
"name": dbName,
"host": dbHost,
"port": dbPort,
"name": dbName,
"username": dbUsername,
"tls": tlsStr,
})

connStr := fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=utf8mb4&parseTime=True&loc=Local&timeout=30s%v", dbUsername, dbPassword, dbHost, dbPort, dbName, tlsStr)
Expand Down
1 change: 1 addition & 0 deletions docs/draft-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
- Error messages during encryption tell you how to fix the issue
- Error messages during encryption log DB row ID
- Checks the database for readability of all fields before attempting encryption or removing salt
- Better logging when setting up database connection leading to improved debug experience

0 comments on commit 691f206

Please sign in to comment.