diff --git a/configuration/configuration.go b/configuration/configuration.go index b6a3bcd..2c55b78 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -11,6 +11,7 @@ import ( ) const ( + varDebugMode = "debug" varPostgresHost = "postgres.host" varPostgresPort = "postgres.port" varPostgresUser = "postgres.user" @@ -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) +} diff --git a/main.go b/main.go index ad558ca..69a8913 100644 --- a/main.go +++ b/main.go @@ -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() diff --git a/openshift/jenkins-proxy.app.yaml b/openshift/jenkins-proxy.app.yaml index f831924..4095f6a 100644 --- a/openshift/jenkins-proxy.app.yaml +++ b/openshift/jenkins-proxy.app.yaml @@ -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} diff --git a/proxy/proxy.go b/proxy/proxy.go index 363543e..2dd56e3 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -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 { diff --git a/storage/service.go b/storage/service.go index 8cc1581..235a425 100644 --- a/storage/service.go +++ b/storage/service.go @@ -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{}) diff --git a/testutils/common.go b/testutils/common.go index 66fa1e0..01b8b61 100644 --- a/testutils/common.go +++ b/testutils/common.go @@ -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",