Documentation
¶
Index ¶
- func NewRedactionCore(core zapcore.Core, redactor *dynamicRedactor) zapcore.Core
- func RedactGlobally(sensitiveValue string)
- func SetLevel(level int8)
- func SetLevelForControl(control levelSetter, level int8)
- func ToLogger(l logr.Logger) *log.Logger
- func ToSlogger(l logr.Logger) *slog.Logger
- func WithConsoleSink(sink io.Writer, opts ...SinkOption) zapcore.Core
- func WithJSONSink(sink io.Writer, opts ...SinkOption) zapcore.Core
- func WithSentry(client *sentry.Client, tags map[string]string) zapcore.Core
- type SinkOption
- type SyncFunc
- func AddSentry(l logr.Logger, client *sentry.Client, tags map[string]string) (logr.Logger, SyncFunc, error)
- func AddSink(l logr.Logger, core zapcore.Core, keysAndValues ...any) (logr.Logger, SyncFunc, error)
- func New(service string, cores ...zapcore.Core) (logr.Logger, SyncFunc)
- func NewWithCaller(service string, addCaller bool, cores ...zapcore.Core) (logr.Logger, SyncFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRedactionCore ¶ added in v3.83.0
NewRedactionCore creates a zapcore.Core that performs redaction of logs in the message and field values.
func RedactGlobally ¶ added in v3.83.0
func RedactGlobally(sensitiveValue string)
RedactGlobally configures the global log redactor to redact the provided value during log emission. The value will be redacted in log messages and values that are strings, but not in log keys or values of other types.
func SetLevel ¶
func SetLevel(level int8)
SetLevel sets the log level for loggers created with the default level controller.
func SetLevelForControl ¶ added in v3.10.0
func SetLevelForControl(control levelSetter, level int8)
SetLevelForControl sets the log level for a given control.
func WithConsoleSink ¶
func WithConsoleSink(sink io.Writer, opts ...SinkOption) zapcore.Core
WithConsoleSink adds a console-style output to the logger.
func WithJSONSink ¶
func WithJSONSink(sink io.Writer, opts ...SinkOption) zapcore.Core
WithJSONSink adds a JSON encoded output to the logger.
Types ¶
type SinkOption ¶ added in v3.93.1
type SinkOption func(*sinkConfig)
func WithGlobalRedaction ¶ added in v3.83.0
func WithGlobalRedaction() SinkOption
WithGlobalRedaction adds values to be redacted from logs.
func WithLevel ¶ added in v3.10.0
func WithLevel(level int8) SinkOption
WithLevel sets the sink's level to a static level. This option prevents changing the log level for this sink later on.
func WithLeveler ¶ added in v3.10.0
func WithLeveler(leveler levelSetter) SinkOption
WithLeveler sets the sink's level enabler to leveler.
func WithSuppressCaller ¶ added in v3.93.1
func WithSuppressCaller() SinkOption
WithSuppressCaller prevents the sink being configured from logging any caller information, irrespective of any other logger settings.
type SyncFunc ¶ added in v3.93.5
type SyncFunc func() error
func AddSentry ¶
func AddSentry(l logr.Logger, client *sentry.Client, tags map[string]string) (logr.Logger, SyncFunc, error)
AddSentry initializes a sentry client and extends an existing logr.Logger with the hook.
func AddSink ¶
AddSink extends an existing logr.Logger with a new sink. It returns the new logr.Logger, a cleanup function, and an error.
The new sink will not inherit any of the existing logger's key-value pairs. Key-value pairs can be added to the new sink specifically by passing them to this function.
func New ¶
New creates a new log object with the provided sinks. If no sinks are provided, a no-op sink will be used. Returns the logger and a cleanup function that should be executed before the program exits.
func NewWithCaller ¶ added in v3.93.1
NewWithCaller creates a new logger named after the specified service with the provided sinks. If addCaller is true, call site information will be attached to each emitted log message. (This behavior can be disabled on a per-sink basis using WithSuppressCaller.)