From 8fa2a02312e4bccb547f71123815a2c6a15db7d3 Mon Sep 17 00:00:00 2001 From: George Blue Date: Tue, 29 Mar 2022 14:10:51 +0100 Subject: [PATCH] fix: log more details when setting up DB connection 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. --- db_service/setup_db.go | 8 +++++--- docs/draft-release-notes.md | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/db_service/setup_db.go b/db_service/setup_db.go index 406d82557..e50711d71 100644 --- a/db_service/setup_db.go +++ b/db_service/setup_db.go @@ -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) diff --git a/docs/draft-release-notes.md b/docs/draft-release-notes.md index 1da4904fb..ccf02ed16 100644 --- a/docs/draft-release-notes.md +++ b/docs/draft-release-notes.md @@ -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