Documentation
¶
Index ¶
- Variables
- func ConsoleEncoder(opts ...EncoderConfigOption) func(o *Options)
- func Encoder(encoder zapcore.Encoder) func(o *Options)
- func JSONEncoder(opts ...EncoderConfigOption) func(o *Options)
- func Level(level zapcore.LevelEnabler) func(o *Options)
- func New(opts ...Opts) logr.Logger
- func NewRaw(opts ...Opts) *zap.Logger
- func RawZapOpts(zapOpts ...zap.Option) func(o *Options)
- func StacktraceLevel(stacktraceLevel zapcore.LevelEnabler) func(o *Options)
- func WithOut(log logr.Logger, w io.Writer) logr.Logger
- type EncoderConfigOption
- type NewEncoderFunc
- type Options
- type Opts
Constants ¶
This section is empty.
Variables ¶
var Log = New(WriteTo(os.Stderr), UseDevMode(true))
Functions ¶
func ConsoleEncoder ¶
func ConsoleEncoder(opts ...EncoderConfigOption) func(o *Options)
ConsoleEncoder configures the logger to use a Console encoder
func Encoder ¶
Encoder configures how the logger will encode the output e.g JSON or console. See Options.Encoder
func JSONEncoder ¶
func JSONEncoder(opts ...EncoderConfigOption) func(o *Options)
JSONEncoder configures the logger to use a JSON Encoder
func Level ¶
func Level(level zapcore.LevelEnabler) func(o *Options)
Level sets the the minimum enabled logging level e.g Debug, Info See Options.Level
func New ¶
New returns a brand new Logger configured with Opts. It uses KubeAwareEncoder which adds Type information and Namespace/Name to the log.
func NewRaw ¶
NewRaw returns a new zap.Logger configured with the passed Opts or their defaults. It uses KubeAwareEncoder which adds Type information and Namespace/Name to the log.
func RawZapOpts ¶
RawZapOpts allows appending arbitrary zap.Options to configure the underlying zap logger. See Options.ZapOpts
func StacktraceLevel ¶
func StacktraceLevel(stacktraceLevel zapcore.LevelEnabler) func(o *Options)
StacktraceLevel configures the logger to record a stack trace for all messages at or above a given level. See Options.StacktraceLevel
Types ¶
type EncoderConfigOption ¶
type EncoderConfigOption func(*zapcore.EncoderConfig)
EncoderConfigOption is a function that can modify a `zapcore.EncoderConfig`.
type NewEncoderFunc ¶
type NewEncoderFunc func(...EncoderConfigOption) zapcore.Encoder
NewEncoderFunc is a function that creates an Encoder using the provided EncoderConfigOptions.
type Options ¶
type Options struct {
// Development configures the logger to use a Zap development config
// (stacktraces on warnings, no sampling), otherwise a Zap production
// config will be used (stacktraces on errors, sampling).
Development bool
// Encoder configures how Zap will encode the output. Defaults to
// console when Development is true and JSON otherwise
Encoder zapcore.Encoder
// EncoderConfigOptions can modify the EncoderConfig needed to initialize an Encoder.
// See https://godoc.org/go.uber.org/zap/zapcore#EncoderConfig for the list of options
// that can be configured.
// Note that the EncoderConfigOptions are not applied when the Encoder option is already set.
EncoderConfigOptions []EncoderConfigOption
// NewEncoder configures Encoder using the provided EncoderConfigOptions.
// Note that the NewEncoder function is not used when the Encoder option is already set.
NewEncoder NewEncoderFunc
// DestWriter controls the destination of the log output. Defaults to
// os.Stderr.
DestWriter io.Writer
// Level configures the verbosity of the logging. Defaults to Debug when
// Development is true and Info otherwise
Level zapcore.LevelEnabler
// StacktraceLevel is the level at and above which stacktraces will
// be recorded for all messages. Defaults to Warn when Development
// is true and Error otherwise
StacktraceLevel zapcore.LevelEnabler
// ZapOpts allows passing arbitrary zap.Options to configure on the
// underlying Zap logger.
ZapOpts []zap.Option
}
Options contains all possible settings
type Opts ¶
type Opts func(*Options)
Opts allows to manipulate Options
func UseDevMode ¶
UseDevMode sets the logger to use (or not use) development mode (more human-readable output, extra stack traces and logging information, etc). See Options.Development