Skip to content

Commit

Permalink
feat: improve logging around db connections
Browse files Browse the repository at this point in the history
...and also removed a log entry for the histogram
  • Loading branch information
pieterlukasse committed Jan 12, 2023
1 parent 94da4ff commit e814e5c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"fmt"
"log"

"github.com/uc-cdis/cohort-middleware/config"
"github.com/uc-cdis/cohort-middleware/utils"
Expand All @@ -28,6 +29,7 @@ func Init() {
port)

dbSchema := c.GetString("atlas_db.schema")
log.Printf("connecting to main 'postgresql' db...")
db, _ := gorm.Open(postgres.New(
postgres.Config{
DSN: dsn,
Expand Down
3 changes: 2 additions & 1 deletion utils/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func GetDataSourceDB(sourceConnectionString string, dbSchema string) *DbAndSchem
dsn := GenerateDsn(sourceConnectionString)
dataSourceDb := new(DbAndSchema)
if strings.Contains(sourceConnectionString, "postgresql") {
log.Printf("trying to connect to 'postgresql' db...")
log.Printf("connecting to cohorts 'postgresql' db...")
// workaround for schema names in postgres (can't be uppercase):
dbSchema = strings.ToLower(dbSchema)
omopDataSource, _ := gorm.Open(postgres.Open(dsn),
Expand All @@ -38,6 +38,7 @@ func GetDataSourceDB(sourceConnectionString string, dbSchema string) *DbAndSchem
}})
dataSourceDb.Db = omopDataSource
} else {
log.Printf("connecting to cohorts 'sqlserver' db...")
omopDataSource, _ := gorm.Open(sqlserver.Open(dsn),
&gorm.Config{
NamingStrategy: schema.NamingStrategy{
Expand Down
1 change: 0 additions & 1 deletion utils/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func GenerateHistogramData(conceptValues []float64) []HistogramColumn {

histogram := []HistogramColumn{}
for binIndex := 0; binIndex < numBins; binIndex++ {
log.Printf("here is the amount of people %v in bin %v", binIndexToHistogramColumn[binIndex].NumberOfPeople, binIndex)
histogram = append(histogram, binIndexToHistogramColumn[binIndex])
}

Expand Down

0 comments on commit e814e5c

Please sign in to comment.