Documentation
¶
Index ¶
- Constants
- func Background() logr.Logger
- func BindCLIFlags(fs *pflag.FlagSet)
- func Flush()
- func FromContextOrBackground(ctx context.Context) logr.Logger
- func NewContext(ctx context.Context, logger logr.Logger) context.Context
- func Noop() logr.Logger
- func Setup(opts *Options)
- func SetupError(msg string, args ...any)
- func ValueAsMap(value any) map[string]any
- type Format
- type Options
- type SLogJSONHandler
Constants ¶
View Source
const ( DefaultFormat = Text DefaultFlushFrequency = 5 * time.Second )
View Source
const ( TimeKey = slog.TimeKey LevelKey = slog.LevelKey VerbosityKey = "v" )
Variables ¶
This section is empty.
Functions ¶
func Background ¶
Background returns the background logger. Current implementation uses klog as the background logger.
func BindCLIFlags ¶ added in v1.29.12
func FromContextOrBackground ¶
FromContextOrBackground returns a logger from the context if it exists, otherwise it returns a background logger. Current implementation uses klog as the background logger.
func NewContext ¶
NewContext returns a new context with the provided logger.
func SetupError ¶ added in v1.29.12
func ValueAsMap ¶
ValueAsMap converts a value to a map[string]any. It returns a map with an "error" key if the conversion fails. NOTE:
It should ONLY be used when the default klog formatter failed to serialize the value in JSON format. Protobuf messages had implemented `String()` method, which the value is hard to read. Use this method to bypass instead.
Types ¶
type Options ¶ added in v1.29.12
func OptionsFromCLIFlags ¶ added in v1.29.12
type SLogJSONHandler ¶ added in v1.29.12
type SLogJSONHandler struct {
// contains filtered or unexported fields
}
func NewJSONHandler ¶ added in v1.29.12
func NewJSONHandler(w io.Writer, opts *slog.HandlerOptions) *SLogJSONHandler
Click to show internal directories.
Click to hide internal directories.