logging

package
v1.8.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2024 License: MPL-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package logging provides logging primitives.

Index

Constants

This section is empty.

Variables

View Source
var StdWriter = &logWrapper{nil}

StdWriter creates a sync writer that writes all logs to the std logger.

Functions

func Component

func Component(name string) zapcore.Field

Component helper for creating zap.Field.

func NewControllerErrorSuppressor added in v1.8.0

func NewControllerErrorSuppressor(core zapcore.Core, threshold int64) zapcore.Core

NewControllerErrorSuppressor creates a new controller error suppressor.

It suppresses error logs for a given controller unless it logs >= threshold errors. The idea is that all controllers reconcile errors, so if the error is not transient, it will be reported enough time to hit the threshold, but transient errors will be suppressed.

The suppressor records the controller name by inspecting a log field named "controller" passed via `logger.With()` call.

func NewWriter

func NewWriter(l *zap.Logger, level zapcore.Level) io.Writer

NewWriter creates new log zap log writer.

func Wrap

func Wrap(writer io.Writer) *zap.Logger

Wrap is a simple helper to wrap io.Writer with default arguments.

func ZapLogger

func ZapLogger(dests ...*LogDestination) *zap.Logger

ZapLogger creates new default Zap Logger.

Types

type LogDestination

type LogDestination struct {
	// contains filtered or unexported fields
}

LogDestination defines logging destination Config.

func NewLogDestination

func NewLogDestination(writer io.Writer, logLevel zapcore.LevelEnabler, options ...LogDestinationOption) *LogDestination

NewLogDestination creates new log destination.

type LogDestinationOption added in v1.8.0

type LogDestinationOption func(dest *LogDestination)

LogDestinationOption defines a log destination encoder config setter.

func WithColoredLevels

func WithColoredLevels() LogDestinationOption

WithColoredLevels enables log level colored output.

func WithControllerErrorSuppressor added in v1.8.0

func WithControllerErrorSuppressor(threshold int64) LogDestinationOption

WithControllerErrorSuppressor creates a new console log controller error suppressor.

func WithoutLogLevels

func WithoutLogLevels() LogDestinationOption

WithoutLogLevels disable log level.

func WithoutTimestamp

func WithoutTimestamp() LogDestinationOption

WithoutTimestamp disables timestamp.

type LogWriter

type LogWriter struct {
	// contains filtered or unexported fields
}

LogWriter is a wrapper around zap.Logger that implements io.Writer interface.

func (*LogWriter) Write

func (lw *LogWriter) Write(line []byte) (int, error)

Write implements io.Writer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL