const LogFlushFreqDefault … const LogFlushFreqFlagName … // NewLoggingConfiguration returns a struct holding the default logging configuration. func NewLoggingConfiguration() *LoggingConfiguration { … } var ReapplyHandling … type ReapplyHandlingType … const ReapplyHandlingError … const ReapplyHandlingIgnoreUnchanged … // ValidateAndApply combines validation and application of the logging configuration. // This should be invoked as early as possible because then the rest of the program // startup (including validation of other options) will already run with the final // logging configuration. // // The optional FeatureGate controls logging features. If nil, the default for // these features is used. // // Logging options must be applied as early as possible during the program // startup. Some changes are global and cannot be done safely when there are // already goroutines running. func ValidateAndApply(c *LoggingConfiguration, featureGate featuregate.FeatureGate) error { … } // ValidateAndApplyWithOptions is a variant of ValidateAndApply which accepts // additional options beyond those that can be configured through the API. This // is meant for testing. // // Logging options must be applied as early as possible during the program // startup. Some changes are global and cannot be done safely when there are // already goroutines running. func ValidateAndApplyWithOptions(c *LoggingConfiguration, options *LoggingOptions, featureGate featuregate.FeatureGate) error { … } type LoggingOptions … // ValidateAndApplyAsField is a variant of ValidateAndApply that should be used // when the LoggingConfiguration is embedded in some larger configuration // structure. func ValidateAndApplyAsField(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) error { … } func validateAndApply(c *LoggingConfiguration, options *LoggingOptions, featureGate featuregate.FeatureGate, fldPath *field.Path) error { … } // Validate can be used to check for invalid settings without applying them. // Most binaries should validate and apply the logging configuration as soon // as possible via ValidateAndApply. The field path is optional: nil // can be passed when the struct is not embedded in some larger struct. func Validate(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) field.ErrorList { … } func validateFormatOptions(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) field.ErrorList { … } func validateTextOptions(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) field.ErrorList { … } func validateJSONOptions(c *LoggingConfiguration, featureGate featuregate.FeatureGate, fldPath *field.Path) field.ErrorList { … } func featureEnabled(featureGate featuregate.FeatureGate, feature featuregate.Feature) bool { … } func apply(c *LoggingConfiguration, options *LoggingOptions, featureGate featuregate.FeatureGate) error { … } type parameters … var applyParameters … // ResetForTest restores the default settings. This is not thread-safe and should only // be used when there are no goroutines running. The intended users are unit // tests in other packages. func ResetForTest(featureGate featuregate.FeatureGate) error { … } // AddFlags adds command line flags for the configuration. func AddFlags(c *LoggingConfiguration, fs *pflag.FlagSet) { … } // AddGoFlags is a variant of AddFlags for a standard FlagSet. func AddGoFlags(c *LoggingConfiguration, fs *flag.FlagSet) { … } type flagSet … type goFlagSet … func (fs goFlagSet) Var(value pflag.Value, name string, usage string) { … } func (fs goFlagSet) VarP(value pflag.Value, name, shorthand, usage string) { … } // addFlags can be used with both flag.FlagSet and pflag.FlagSet. The internal // interface definition avoids duplicating this code. func addFlags(c *LoggingConfiguration, fs flagSet) { … } // SetRecommendedLoggingConfiguration sets the default logging configuration // for fields that are unset. // // Consumers who embed LoggingConfiguration in their own configuration structs // may set custom defaults and then should call this function to add the // global defaults. func SetRecommendedLoggingConfiguration(c *LoggingConfiguration) { … } func setRecommendedOutputRouting(o *OutputRoutingOptions) { … } var loggingFlags … func init() { … } var supportedLogsFlags … // unsupportedLoggingFlags lists unsupported logging flags. The normalize // function is optional. func unsupportedLoggingFlags(normalizeFunc func(f *pflag.FlagSet, name string) pflag.NormalizedName) []*pflag.Flag { … }