1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-03-17 21:17:53 +02:00

Ensure exclude-logging-paths is consistent with other options

This commit is contained in:
Joel Speed 2020-05-24 21:59:18 +01:00
parent f7c88f53d1
commit 94e31f8b65
No known key found for this signature in database
GPG Key ID: 6E80578D6751DEFB
2 changed files with 4 additions and 6 deletions

View File

@ -13,7 +13,7 @@ type Logging struct {
RequestFormat string `flag:"request-logging-format" cfg:"request_logging_format"`
StandardEnabled bool `flag:"standard-logging" cfg:"standard_logging"`
StandardFormat string `flag:"standard-logging-format" cfg:"standard_logging_format"`
ExcludePaths string `flag:"exclude-logging-paths" cfg:"exclude_logging_paths"`
ExcludePaths []string `flag:"exclude-logging-path" cfg:"exclude_logging_paths"`
LocalTime bool `flag:"logging-local-time" cfg:"logging_local_time"`
SilencePing bool `flag:"silence-ping-logging" cfg:"silence_ping_logging"`
File LogFileOptions `cfg:",squash"`
@ -38,7 +38,7 @@ func loggingFlagSet() *pflag.FlagSet {
flagSet.Bool("request-logging", true, "Log HTTP requests")
flagSet.String("request-logging-format", logger.DefaultRequestLoggingFormat, "Template for HTTP request log lines")
flagSet.String("exclude-logging-paths", "", "Exclude logging requests to paths (eg: '/path1,/path2,/path3')")
flagSet.StringSlice("exclude-logging-path", []string{}, "Exclude logging requests to paths (eg: '/path1,/path2,/path3')")
flagSet.Bool("logging-local-time", true, "If the time in log files and backup filenames are local or UTC time")
flagSet.Bool("silence-ping-logging", false, "Disable logging of requests to ping endpoint")
@ -54,6 +54,7 @@ func loggingFlagSet() *pflag.FlagSet {
// loggingDefaults creates a Logging structure, populating each field with its default value
func loggingDefaults() Logging {
return Logging{
ExcludePaths: nil,
LocalTime: true,
SilencePing: false,
AuthEnabled: true,

View File

@ -2,7 +2,6 @@ package validation
import (
"os"
"strings"
"github.com/oauth2-proxy/oauth2-proxy/pkg/apis/options"
"github.com/oauth2-proxy/oauth2-proxy/pkg/logger"
@ -49,12 +48,10 @@ func configureLogger(o options.Logging, pingPath string, msgs []string) []string
logger.SetAuthTemplate(o.AuthFormat)
logger.SetReqTemplate(o.RequestFormat)
excludePaths := make([]string, 0)
excludePaths = append(excludePaths, strings.Split(o.ExcludePaths, ",")...)
excludePaths := o.ExcludePaths
if o.SilencePing {
excludePaths = append(excludePaths, pingPath)
}
logger.SetExcludePaths(excludePaths)
if !o.LocalTime {