log

package
v0.0.0-...-042a028 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 39

Documentation

Overview

Package log contains the CloudNativePG logging infrastructure

Package log contains the logging subsystem of the instance manager

Index

Constants

View Source
const (
	// ErrorLevelString is the string representation of the error level
	ErrorLevelString = "error"
	// ErrorLevel is the error level priority
	ErrorLevel = zapcore.ErrorLevel

	// InfoLevelString is the string representation of the info level
	InfoLevelString = "info"
	// InfoLevel is the info level priority
	InfoLevel = zapcore.InfoLevel

	// DebugLevelString is the string representation of the debug level
	DebugLevelString = "debug"
	// DebugLevel is the debug level priority
	DebugLevel zapcore.Level = -2

	// TraceLevelString is the string representation of the trace level
	TraceLevelString = "trace"
	// TraceLevel is the trace level priority
	TraceLevel zapcore.Level = -4

	// WarningLevelString is the string representation of the warning level
	WarningLevelString = "warning"
	// WarningLevel is the warning level priority
	WarningLevel = zapcore.WarnLevel

	// DefaultLevelString is the string representation of the default level
	DefaultLevelString = InfoLevelString
	// DefaultLevel is the default logging level
	DefaultLevel = InfoLevel
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, keysAndValues ...interface{})

Debug exposes the same method from the logr.Logger interface using the default logger

func Enabled

func Enabled() bool

Enabled exposes the same method from the logr.Logger interface using the default logger

func Error

func Error(err error, msg string, keysAndValues ...interface{})

Error exposes the same method from the logr.Logger interface using the default logger

func GetFieldsRemapFlags

func GetFieldsRemapFlags() (res []string)

GetFieldsRemapFlags returns the required flags to set the logging fields

func Info

func Info(msg string, keysAndValues ...interface{})

Info exposes the same method from the logr.Logger interface using the default logger

func IntoContext

func IntoContext(ctx context.Context, log Logger) context.Context

IntoContext injects a logger into a context

func SetLogLevel

func SetLogLevel(level string)

SetLogLevel sets manually the logLevel

func SetLogger

func SetLogger(logr logr.Logger)

SetLogger will set the backing logr implementation for instance manager.

func Trace

func Trace(msg string, keysAndValues ...interface{})

Trace exposes the same method from the logr.Logger interface using the default logger

func Warning

func Warning(msg string, keysAndValues ...interface{})

Warning exposes the same method from the logr.Logger interface using the default logger

Types

type Flags

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

Flags contains the set of values necessary for configuring the manager

func NewFlags

func NewFlags(options zap.Options) Flags

NewFlags creates a new instance of Flags

func (*Flags) AddFlags

func (l *Flags) AddFlags(flags *pflag.FlagSet)

AddFlags binds manager configuration flags to a given flagset

func (*Flags) ConfigureLogging

func (l *Flags) ConfigureLogging()

ConfigureLogging configure the logging honoring the flags passed from the user This is executed after args were already parsed.

type Logger

type Logger interface {
	Enabled() bool
	Error(err error, msg string, keysAndValues ...interface{})
	Warning(msg string, keysAndValues ...interface{})
	Info(msg string, keysAndValues ...interface{})
	Debug(msg string, keysAndValues ...interface{})
	Trace(msg string, keysAndValues ...interface{})
	WithCaller() Logger
	WithValues(keysAndValues ...interface{}) Logger
	WithName(name string) Logger
	GetLogger() logr.Logger
}

Logger is a reduced version of logr.Logger

func FromContext

func FromContext(ctx context.Context) Logger

FromContext builds a logger with some additional information stored in the context

func GetLogger

func GetLogger() Logger

GetLogger returns the default logger

func SetupLogger

func SetupLogger(ctx context.Context) (Logger, context.Context)

SetupLogger sets up the logger from a given context, wrapping it with a new uuid, and any given name

func WithCaller

func WithCaller() Logger

WithCaller exposes the same method from logr.Logger interface using the default logger

func WithName

func WithName(name string) Logger

WithName exposes the same method from the logr.Logger interface using the default logger

func WithValues

func WithValues(keysAndValues ...interface{}) Logger

WithValues exposes the same method from the logr.Logger interface using the default logger

Jump to

Keyboard shortcuts

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