Documentation ¶
Overview ¶
Package logs contains support for logging options, flags and setup. Commands must explicitly enable command line flags. They no longer get added automatically when importing this package.
Index ¶
- Constants
- func AddFlags(fs *pflag.FlagSet)
- func AddGoFlags(fs *flag.FlagSet)
- func BindLoggingFlags(c *config.LoggingConfiguration, fs *pflag.FlagSet)
- func FlushLogs()
- func GlogSetter(val string) (string, error)
- func InitLogs()
- func NewLogger(prefix string) *log.Logger
- func UnsupportedLoggingFlags(normalizeFunc func(f *pflag.FlagSet, name string) pflag.NormalizedName) []*pflag.Flag
- func ValidateLoggingConfiguration(c *config.LoggingConfiguration, fldPath *field.Path) field.ErrorList
- type KlogWriter
- type Options
Constants ¶
const ( DefaultLogFormat = "text" JSONLogFormat = "json" )
Supported klog formats
Variables ¶
This section is empty.
Functions ¶
func AddFlags ¶
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 AddGoFlags ¶ added in v0.23.0
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 BindLoggingFlags ¶ added in v0.22.0
func BindLoggingFlags(c *config.LoggingConfiguration, fs *pflag.FlagSet)
BindLoggingFlags binds the Options struct fields to a flagset
func FlushLogs ¶
func FlushLogs()
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 GlogSetter ¶
GlogSetter is a setter to set glog level.
func InitLogs ¶
func InitLogs()
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.
func UnsupportedLoggingFlags ¶ added in v0.22.0
func UnsupportedLoggingFlags(normalizeFunc func(f *pflag.FlagSet, name string) pflag.NormalizedName) []*pflag.Flag
UnsupportedLoggingFlags lists unsupported logging flags. The normalize function is optional.
func ValidateLoggingConfiguration ¶ added in v0.22.0
Types ¶
type KlogWriter ¶
type KlogWriter struct{}
KlogWriter serves as a bridge between the standard log package and the glog package.
type Options ¶ added in v0.19.0
type Options struct {
Config config.LoggingConfiguration
}
Options has klog format parameters
Directories ¶
Path | Synopsis |
---|---|
Package datapol contains functions to determine if objects contain sensitive data to e.g.
|
Package datapol contains functions to determine if objects contain sensitive data to e.g. |
example
|
|
Package testinit adds logging flags to a Ginkgo or Go test program during initialization, something that the logs package itself no longer does.
|
Package testinit adds logging flags to a Ginkgo or Go test program during initialization, something that the logs package itself no longer does. |