log

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package log contains the logging subsystem of PGK

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 AddUUID

func AddUUID(ctx context.Context) (context.Context, error)

AddUUID wraps a given context to inject a new uuid

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 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 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 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