-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
199 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package options | ||
|
||
import ( | ||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/logger" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
// Logging contains all options required for configuring the logging | ||
type LegacyLogging struct { | ||
AuthEnabled bool `flag:"auth-logging" cfg:"auth_logging"` | ||
AuthFormat string `flag:"auth-logging-format" cfg:"auth_logging_format"` | ||
RequestEnabled bool `flag:"request-logging" cfg:"request_logging"` | ||
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"` | ||
ErrToInfo bool `flag:"errors-to-info-log" cfg:"errors_to_info_log"` | ||
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"` | ||
RequestIDHeader string `flag:"request-id-header" cfg:"request_id_header"` | ||
File LegacyLogFileOptions `cfg:",squash"` | ||
} | ||
|
||
// LogFileOptions contains options for configuring logging to a file | ||
type LegacyLogFileOptions struct { | ||
Filename string `flag:"logging-filename" cfg:"logging_filename"` | ||
MaxSize int `flag:"logging-max-size" cfg:"logging_max_size"` | ||
MaxAge int `flag:"logging-max-age" cfg:"logging_max_age"` | ||
MaxBackups int `flag:"logging-max-backups" cfg:"logging_max_backups"` | ||
Compress bool `flag:"logging-compress" cfg:"logging_compress"` | ||
} | ||
|
||
func legacyLoggingFlagSet() *pflag.FlagSet { | ||
flagSet := pflag.NewFlagSet("logging", pflag.ExitOnError) | ||
|
||
flagSet.Bool("auth-logging", true, "Log authentication attempts") | ||
flagSet.String("auth-logging-format", logger.DefaultAuthLoggingFormat, "Template for authentication log lines") | ||
flagSet.Bool("standard-logging", true, "Log standard runtime information") | ||
flagSet.String("standard-logging-format", logger.DefaultStandardLoggingFormat, "Template for standard log lines") | ||
flagSet.Bool("request-logging", true, "Log HTTP requests") | ||
flagSet.String("request-logging-format", logger.DefaultRequestLoggingFormat, "Template for HTTP request log lines") | ||
flagSet.Bool("errors-to-info-log", false, "Log errors to the standard logging channel instead of stderr") | ||
|
||
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 & ready endpoints") | ||
flagSet.String("request-id-header", "X-Request-Id", "Request header to use as the request ID") | ||
|
||
flagSet.String("logging-filename", "", "File to log requests to, empty for stdout") | ||
flagSet.Int("logging-max-size", 100, "Maximum size in megabytes of the log file before rotation") | ||
flagSet.Int("logging-max-age", 7, "Maximum number of days to retain old log files") | ||
flagSet.Int("logging-max-backups", 0, "Maximum number of old log files to retain; 0 to disable") | ||
flagSet.Bool("logging-compress", false, "Should rotated log files be compressed using gzip") | ||
|
||
return flagSet | ||
} | ||
|
||
func (l *LegacyLogging) convert() Logging { | ||
return Logging{ | ||
AuthEnabled: l.AuthEnabled, | ||
AuthFormat: l.AuthFormat, | ||
RequestEnabled: l.RequestEnabled, | ||
RequestFormat: l.RequestFormat, | ||
StandardEnabled: l.StandardEnabled, | ||
StandardFormat: l.StandardFormat, | ||
ErrToInfo: l.ErrToInfo, | ||
ExcludePaths: l.ExcludePaths, | ||
LocalTime: l.LocalTime, | ||
SilencePing: l.SilencePing, | ||
RequestIDHeader: l.RequestIDHeader, | ||
File: LogFileOptions{ | ||
Filename: l.File.Filename, | ||
MaxSize: l.File.MaxSize, | ||
MaxAge: l.File.MaxAge, | ||
MaxBackups: l.File.MaxBackups, | ||
Compress: l.File.Compress, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters