Skip to content

Commit

Permalink
Add configuration option for debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vpavlin committed Dec 11, 2017
1 parent 303ab18 commit 5f8cdd7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

const (
varDebugMode = "debug"
varPostgresHost = "postgres.host"
varPostgresPort = "postgres.port"
varPostgresUser = "postgres.user"
Expand Down Expand Up @@ -248,3 +249,8 @@ func (c *Data) GetMaxRequestretry() int {
func (c *Data) GetLocalDevEnv() bool {
return c.v.GetBool(varLocalDevEnv)
}

// GetDebugMode returns if debug mode should be enabled as set via default, config file, or environment variable
func (c *Data) GetDebugMode() bool {
return c.v.GetBool(varDebugMode)
}
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func main() {
log.Fatal(err)
}

if config.GetDebugMode() {
log.SetLevel(log.DebugLevel)
}

//Run mock services if this is local dev env
if config.GetLocalDevEnv() {
testutils.Run()
Expand Down
2 changes: 2 additions & 0 deletions openshift/jenkins-proxy.app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ objects:
secretKeyRef:
name: jenkins-proxy
key: postgres.password
- name: JC_DEBUG
value: true
- name: GODEBUG
value: gctrace=1
image: ${IMAGE}:${IMAGE_TAG}
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (p *Proxy) RecordStatistics(ns string, la int64, lbf int64) (err error) {
}
}
if notFound {
log.Info("New user %s", ns)
log.Infof("New user %s", ns)
s = storage.NewStatistics(ns, la, lbf)
}
if la != 0 {
Expand Down
3 changes: 3 additions & 0 deletions storage/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func Connect(config *configuration.Data) *gorm.DB {
db.DB().SetMaxOpenConns(config.GetPostgresConnectionMaxOpen())
}

if config.GetDebugMode() {
db = db.Debug()
}
db.CreateTable(&Request{})
db.CreateTable(&Statistics{})

Expand Down
2 changes: 1 addition & 1 deletion testutils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func TenantData1(url string) []byte {
{
"cluster-url":"%s",
"created-at":"2017-10-11T18:47:28.491233Z",
"name":"vpavlin-jenkins",
"name":"vpavlin-osiotest1-jenkins",
"state":"created",
"type":"jenkins",
"updated-at":"2017-10-11T18:47:28.491233Z",
Expand Down

0 comments on commit 5f8cdd7

Please sign in to comment.