mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 01:09:36 +02:00
config: validate log levels (#4367)
* config: validate log levels * fix SetLevel * document unset, merge warn/warning
This commit is contained in:
parent
a1388592d8
commit
78e7a3e7d0
8 changed files with 152 additions and 30 deletions
|
@ -37,7 +37,7 @@ const (
|
|||
|
||||
type serverOptions struct {
|
||||
services string
|
||||
logLevel string
|
||||
logLevel config.LogLevel
|
||||
}
|
||||
|
||||
// A Server is a pomerium proxy implemented via envoy.
|
||||
|
@ -113,7 +113,7 @@ func (srv *Server) update(ctx context.Context, cfg *config.Config) {
|
|||
|
||||
options := serverOptions{
|
||||
services: cfg.Options.Services,
|
||||
logLevel: firstNonEmpty(cfg.Options.ProxyLogLevel, cfg.Options.LogLevel, "debug"),
|
||||
logLevel: firstNonEmpty(cfg.Options.ProxyLogLevel, cfg.Options.LogLevel, config.LogLevelDebug),
|
||||
}
|
||||
|
||||
if cmp.Equal(srv.options, options, cmp.AllowUnexported(serverOptions{})) {
|
||||
|
@ -140,7 +140,7 @@ func (srv *Server) run(ctx context.Context, cfg *config.Config) error {
|
|||
|
||||
args := []string{
|
||||
"-c", configFileName,
|
||||
"--log-level", srv.options.logLevel,
|
||||
"--log-level", srv.options.logLevel.ToEnvoy(),
|
||||
"--log-format", "[LOG_FORMAT]%l--%n--%v",
|
||||
"--log-format-escaped",
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
|
||||
)
|
||||
|
||||
func firstNonEmpty(args ...string) string {
|
||||
func firstNonEmpty[T interface{ ~string }](args ...T) T {
|
||||
for _, a := range args {
|
||||
if a != "" {
|
||||
return a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue