diff --git a/cmd/loki/main.go b/cmd/loki/main.go index beb665fc5dff34b86de8978542c9c2c15a684108..60676cf3603acfc2964c210840a39cbaefa5842f 100644 --- a/cmd/loki/main.go +++ b/cmd/loki/main.go @@ -4,12 +4,14 @@ import ( "flag" "fmt" "os" + "reflect" "github.com/go-kit/kit/log/level" "github.com/grafana/loki/pkg/helpers" "github.com/grafana/loki/pkg/loki" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/version" + "github.com/weaveworks/common/logging" "github.com/weaveworks/common/tracing" "github.com/cortexproject/cortex/pkg/util" @@ -49,6 +51,10 @@ func main() { } // Re-init the logger which will now honor a different log level set in cfg.Server + if reflect.DeepEqual(&cfg.Server.LogLevel, &logging.Level{}) { + level.Error(util.Logger).Log("msg", "invalid log level") + os.Exit(1) + } util.InitLogger(&cfg.Server) // Setting the environment variable JAEGER_AGENT_HOST enables tracing diff --git a/cmd/promtail/main.go b/cmd/promtail/main.go index ba9fb026d9e98dc8aab9a6fd05891d6b4660c3da..fac17045e319d065deb529c60aa94901be6d3cf9 100644 --- a/cmd/promtail/main.go +++ b/cmd/promtail/main.go @@ -3,12 +3,14 @@ package main import ( "flag" "os" + "reflect" "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/go-kit/kit/log/level" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/version" + "github.com/weaveworks/common/logging" "github.com/grafana/loki/pkg/helpers" "github.com/grafana/loki/pkg/promtail" @@ -38,6 +40,10 @@ func main() { } // Re-init the logger which will now honor a different log level set in ServerConfig.Config + if reflect.DeepEqual(&config.ServerConfig.Config.LogLevel, &logging.Level{}) { + level.Error(util.Logger).Log("msg", "invalid log level") + os.Exit(1) + } util.InitLogger(&config.ServerConfig.Config) p, err := promtail.New(config)