Skip to content

Commit

Permalink
logging output level available as config option
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblakeley committed Oct 12, 2017
1 parent 12e09bd commit 690ee0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ type Config struct {
ReloadWaitTime int `bson:"reload_wait_time" json:"reload_wait_time"`
ProxySSLInsecureSkipVerify bool `json:"proxy_ssl_insecure_skip_verify"`
ProxyDefaultTimeout int `json:"proxy_default_timeout"`
LogLevel string `json:"log_level"`
}

type CertData struct {
Expand Down
17 changes: 17 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,23 @@ func initialiseSystem(arguments map[string]interface{}) error {
afterConfSetup(&config.Global)
}

if os.Getenv("TYK_LOGLEVEL") == "" && arguments["--debug"] == false {
switch strings.ToLower(config.Global.LogLevel) {
case "", "info":
//defualt, do nothing
case "error":
log.Level = logrus.ErrorLevel
case "warn":
log.Level = logrus.WarnLevel
case "debug":
log.Level = logrus.DebugLevel
default:
log.WithFields(logrus.Fields{
"prefix": "main",
}).Fatal("Invalid log level in config, must be error, warn or debug.")
}
}

if config.Global.Storage.Type != "redis" {
log.WithFields(logrus.Fields{
"prefix": "main",
Expand Down

0 comments on commit 690ee0a

Please sign in to comment.