log

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package log contains series of utilities for setting up and accessing logger. We use logr.Logger as the facade of each logger.

See https://github.com/chaos-mesh/rfcs/blob/main/text/2021-12-09-logging.md for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnrichLoggerWithContext

func EnrichLoggerWithContext(ctx context.Context, logger logr.Logger) logr.Logger

func L deprecated

func L() logr.Logger

L is the way to access the global logger. You could use it if there are no logger in your code context. Please notice that the default value of "global logger" is a "discard logger" which means that all logs will be ignored. Make sure that initialize the global logger by ReplaceGlobals before using it, for example, calling ReplaceGlobals at the beginning of your main function.

Do NOT save the global logger to a variable for long-term using, because it is possible that the global logger is replaced by another. Keep calling L at each time.

Deprecated: Do not use global logger anymore. For more detail, see https://github.com/chaos-mesh/rfcs/blob/main/text/2021-12-09-logging.md#global-logger

func NewDefaultZapLogger

func NewDefaultZapLogger() (logr.Logger, error)

NewDefaultZapLogger is the recommended way to create a new logger, you could call this function to initialize the root logger of your application, and provide it to your components, by fx or manually.

func NewZapLoggerWithWriter

func NewZapLoggerWithWriter(out io.Writer) logr.Logger

NewZapLoggerWithWriter creates a new logger with io.writer The provided encoder presets NewDevelopmentEncoderConfig used by NewDevelopmentConfig do not enable function name logging. To enable function name, a non-empty value for config.EncoderConfig.FunctionKey.

func ReplaceGlobals deprecated

func ReplaceGlobals(logger logr.Logger)

ReplaceGlobals would replace the global logger with the given logger. It should be used when your application starting.

Deprecated: Do not use global logger anymore. For more detail, see https://github.com/chaos-mesh/rfcs/blob/main/text/2021-12-09-logging.md#global-logger

Types

type LogrPrinter

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

func NewLogrPrinter

func NewLogrPrinter(logger logr.Logger) *LogrPrinter

func (*LogrPrinter) Printf

func (it *LogrPrinter) Printf(s string, i ...interface{})

type Metadatkey

type Metadatkey string
const (
	MetaNamespacedName Metadatkey = "namespaced-name"
)

Jump to

Keyboard shortcuts

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