Skip to content

Commit

Permalink
chore: fix postgres logging
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Zapletal <[email protected]>
  • Loading branch information
lzap authored and ezr-ondrej committed Nov 13, 2023
1 parent 801f146 commit 4179f32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/api.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
# cloudwatch logging stream (default "")
# DATABASE_HOST string
# main database hostname (default "localhost")
# DATABASE_LOG_LEVEL string
# DATABASE_LOGGING_LEVEL string
# logging level of database logs (default "info")
# DATABASE_MAX_CONN int32
# connection pool maximum size (default "50")
Expand Down
22 changes: 11 additions & 11 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ var config struct {
CleanupInterval time.Duration `env:"CLEANUP_INTERVAL" env-default:"1h" env-description:"how often to cleanup the reservation"`
} `env-prefix:"RESERVATION_"`
Database struct {
Host string `env:"HOST" env-default:"localhost" env-description:"main database hostname"`
Port uint16 `env:"PORT" env-default:"5432" env-description:"main database port"`
Name string `env:"NAME" env-default:"provisioning" env-description:"main database name"`
User string `env:"USER" env-default:"postgres" env-description:"main database username"`
Password string `env:"PASSWORD" env-default:"" env-description:"main database password"`
SeedScript string `env:"SEED_SCRIPT" env-default:"" env-description:"database seed script (dev only)"`
MinConn int32 `env:"MIN_CONN" env-default:"2" env-description:"connection pool minimum size"`
MaxConn int32 `env:"MAX_CONN" env-default:"50" env-description:"connection pool maximum size"`
MaxIdleTime time.Duration `env:"MAX_IDLE_TIME" env-default:"15m" env-description:"connection pool idle time (time interval syntax)"`
MaxLifetime time.Duration `env:"MAX_LIFETIME" env-default:"2h" env-description:"connection pool total lifetime (time interval syntax)"`
LogLevel string `env:"LOG_LEVEL" env-default:"info" env-description:"logging level of database logs"`
Host string `env:"HOST" env-default:"localhost" env-description:"main database hostname"`
Port uint16 `env:"PORT" env-default:"5432" env-description:"main database port"`
Name string `env:"NAME" env-default:"provisioning" env-description:"main database name"`
User string `env:"USER" env-default:"postgres" env-description:"main database username"`
Password string `env:"PASSWORD" env-default:"" env-description:"main database password"`
SeedScript string `env:"SEED_SCRIPT" env-default:"" env-description:"database seed script (dev only)"`
MinConn int32 `env:"MIN_CONN" env-default:"2" env-description:"connection pool minimum size"`
MaxConn int32 `env:"MAX_CONN" env-default:"50" env-description:"connection pool maximum size"`
MaxIdleTime time.Duration `env:"MAX_IDLE_TIME" env-default:"15m" env-description:"connection pool idle time (time interval syntax)"`
MaxLifetime time.Duration `env:"MAX_LIFETIME" env-default:"2h" env-description:"connection pool total lifetime (time interval syntax)"`
LoggingLevel string `env:"LOGGING_LEVEL" env-default:"info" env-description:"logging level of database logs"`
} `env-prefix:"DATABASE_"`
Logging struct {
Level string `env:"LEVEL" env-default:"info" env-description:"logger level (trace, debug, info, warn, error, fatal, panic)"`
Expand Down
2 changes: 1 addition & 1 deletion internal/db/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Initialize(ctx context.Context, schema string) error {
if config.Telemetry.Enabled {
poolConfig.ConnConfig.Tracer = otelpgx.NewTracer(otelpgx.WithIncludeQueryParameters())
} else {
logLevel, configErr := tracelog.LogLevelFromString(config.Database.LogLevel)
logLevel, configErr := tracelog.LogLevelFromString(config.Database.LoggingLevel)
if configErr != nil {
return fmt.Errorf("cannot parse db log level configuration: %w", configErr)
}
Expand Down

0 comments on commit 4179f32

Please sign in to comment.