Ensure exclude-logging-paths is consistent with other options
This commit is contained in:
		
							parent
							
								
									f7c88f53d1
								
							
						
					
					
						commit
						94e31f8b65
					
				|  | @ -13,7 +13,7 @@ type Logging struct { | ||||||
| 	RequestFormat   string         `flag:"request-logging-format" cfg:"request_logging_format"` | 	RequestFormat   string         `flag:"request-logging-format" cfg:"request_logging_format"` | ||||||
| 	StandardEnabled bool           `flag:"standard-logging" cfg:"standard_logging"` | 	StandardEnabled bool           `flag:"standard-logging" cfg:"standard_logging"` | ||||||
| 	StandardFormat  string         `flag:"standard-logging-format" cfg:"standard_logging_format"` | 	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"` | 	LocalTime       bool           `flag:"logging-local-time" cfg:"logging_local_time"` | ||||||
| 	SilencePing     bool           `flag:"silence-ping-logging" cfg:"silence_ping_logging"` | 	SilencePing     bool           `flag:"silence-ping-logging" cfg:"silence_ping_logging"` | ||||||
| 	File            LogFileOptions `cfg:",squash"` | 	File            LogFileOptions `cfg:",squash"` | ||||||
|  | @ -38,7 +38,7 @@ func loggingFlagSet() *pflag.FlagSet { | ||||||
| 	flagSet.Bool("request-logging", true, "Log HTTP requests") | 	flagSet.Bool("request-logging", true, "Log HTTP requests") | ||||||
| 	flagSet.String("request-logging-format", logger.DefaultRequestLoggingFormat, "Template for HTTP request log lines") | 	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("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") | 	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
 | // loggingDefaults creates a Logging structure, populating each field with its default value
 | ||||||
| func loggingDefaults() Logging { | func loggingDefaults() Logging { | ||||||
| 	return Logging{ | 	return Logging{ | ||||||
|  | 		ExcludePaths:    nil, | ||||||
| 		LocalTime:       true, | 		LocalTime:       true, | ||||||
| 		SilencePing:     false, | 		SilencePing:     false, | ||||||
| 		AuthEnabled:     true, | 		AuthEnabled:     true, | ||||||
|  |  | ||||||
|  | @ -2,7 +2,6 @@ package validation | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"os" | 	"os" | ||||||
| 	"strings" |  | ||||||
| 
 | 
 | ||||||
| 	"github.com/oauth2-proxy/oauth2-proxy/pkg/apis/options" | 	"github.com/oauth2-proxy/oauth2-proxy/pkg/apis/options" | ||||||
| 	"github.com/oauth2-proxy/oauth2-proxy/pkg/logger" | 	"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.SetAuthTemplate(o.AuthFormat) | ||||||
| 	logger.SetReqTemplate(o.RequestFormat) | 	logger.SetReqTemplate(o.RequestFormat) | ||||||
| 
 | 
 | ||||||
| 	excludePaths := make([]string, 0) | 	excludePaths := o.ExcludePaths | ||||||
| 	excludePaths = append(excludePaths, strings.Split(o.ExcludePaths, ",")...) |  | ||||||
| 	if o.SilencePing { | 	if o.SilencePing { | ||||||
| 		excludePaths = append(excludePaths, pingPath) | 		excludePaths = append(excludePaths, pingPath) | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	logger.SetExcludePaths(excludePaths) | 	logger.SetExcludePaths(excludePaths) | ||||||
| 
 | 
 | ||||||
| 	if !o.LocalTime { | 	if !o.LocalTime { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue