Fix parsing env var, needed to be in the helper too

This commit is contained in:
Jeff Mitchell 2016-09-23 13:20:26 -04:00
parent be694f0287
commit 72b9c4c649
2 changed files with 7 additions and 3 deletions

View File

@ -101,7 +101,7 @@ func (c *ServerCommand) Run(args []string) int {
logFormat = os.Getenv("LOGXI_FORMAT") logFormat = os.Getenv("LOGXI_FORMAT")
} }
switch strings.ToLower(logFormat) { switch strings.ToLower(logFormat) {
case "vault", "vault_json", "vault-json", "vaultjson", "": case "vault", "vault_json", "vault-json", "vaultjson", "json", "":
c.logger = logformat.NewVaultLoggerWithWriter(logGate, level) c.logger = logformat.NewVaultLoggerWithWriter(logGate, level)
default: default:
c.logger = log.NewLogger(logGate, "vault") c.logger = log.NewLogger(logGate, "vault")

View File

@ -43,8 +43,12 @@ func createVaultFormatter() log.Formatter {
ret := &vaultFormatter{ ret := &vaultFormatter{
Mutex: &sync.Mutex{}, Mutex: &sync.Mutex{},
} }
switch os.Getenv("LOGXI_FORMAT") { logFormat := os.Getenv("VAULT_LOG_FORMAT")
case "vault_json", "vault-json", "vaultjson": if logFormat == "" {
logFormat = os.Getenv("LOGXI_FORMAT")
}
switch strings.ToLower(logFormat) {
case "json", "vault_json", "vault-json", "vaultjson":
ret.style = stylejson ret.style = stylejson
default: default:
ret.style = styledefault ret.style = styledefault