logger

package
v0.0.0-...-cc2f144 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, keyAndValues ...interface{}) logr.Logger

FromContext returns a logr.Logger instance based on the provided context and key-value pairs. The logger is retrieved from the context using clog.FromContext method. The key-value pairs are optional and can be used for additional logging information. It expects a context.Context as the first argument, followed by optional key-value pairs. It returns a logr.Logger instance.

func InitCmdLogger

func InitCmdLogger(rootCmd *cobra.Command)

InitCmdLogger setup callback that initializes the logger configuration.

func InitLogger

func InitLogger() logr.Logger

InitLogger initializes the logger.

func WithContext

func WithContext(ctx context.Context, log logr.Logger) context.Context

WithContext adds a logr.Logger to the provided context. The logr.Logger is added using clog.IntoContext(). The context returned will have the added logr.Logger included.

Example usage:

ctx := context.Background()
logger := logr.New()
ctxWithLogger := WithContext(ctx, logger)

Parameters:

  • ctx: The context to add the logger to.
  • log: The logr.Logger to add to the context.

Returns:

The modified context with the added logr.Logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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