const vmoduleUsage … var packageFlags … var logFlushFreq … func init() { … } type addFlagsOptions … type Option … // SkipLoggingConfigurationFlags must be used as option for AddFlags when // the program also uses a LoggingConfiguration struct for configuring // logging. Then only flags not covered by that get added. func SkipLoggingConfigurationFlags() Option { … } type Options … var NewOptions … // AddFlags registers this package's flags on arbitrary FlagSets. This includes // the klog flags, with the original underscore as separator between. If // commands want hyphens as separators, they can set // k8s.io/component-base/cli/flag/WordSepNormalizeFunc as normalization // function on the flag set before calling AddFlags. // // May be called more than once. func AddFlags(fs *pflag.FlagSet, opts ...Option) { … } // AddGoFlags is a variant of AddFlags for traditional Go flag.FlagSet. // Commands should use pflag whenever possible for the sake of consistency. // Cases where this function is needed include tests (they have to set up flags // in flag.CommandLine) and commands that for historic reasons use Go // flag.Parse and cannot change to pflag because it would break their command // line interface. func AddGoFlags(fs *flag.FlagSet, opts ...Option) { … } type KlogWriter … // Write implements the io.Writer interface. func (writer KlogWriter) Write(data []byte) (n int, err error) { … } // InitLogs initializes logs the way we want for Kubernetes. // It should be called after parsing flags. If called before that, // it will use the default log settings. // // InitLogs disables support for contextual logging in klog while // that Kubernetes feature is not considered stable yet. Commands // which want to support contextual logging can: // - call klog.EnableContextualLogging after calling InitLogs, // with a fixed `true` or depending on some command line flag or // a feature gate check // - set up a FeatureGate instance, the advanced logging configuration // with Options and call Options.ValidateAndApply with the FeatureGate; // k8s.io/component-base/logs/example/cmd demonstrates how to do that func InitLogs() { … } // FlushLogs flushes logs immediately. This should be called at the end of // the main function via defer to ensure that all pending log messages // are printed before exiting the program. func FlushLogs() { … } // NewLogger creates a new log.Logger which sends logs to klog.Info. func NewLogger(prefix string) *log.Logger { … } // GlogSetter modifies the verbosity threshold for the entire program. // Some components have HTTP-based APIs for invoking this at runtime. func GlogSetter(val string) (string, error) { … }