log

package
v0.0.0-...-9dcacef Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextKey is the string key used to store a logger in a Context
	ContextKey = "grm-generate.logger"
)

Variables

This section is empty.

Functions

func New

func New(
	log logr.Logger,
	vals ...interface{},
) *logger

New returns a logger that can write log messages about API discovery and code generation processes.

Types

type Logger

type Logger interface {
	// IsDebugEnabled returns true when the underlying logger is configured to
	// write debug messages, false otherwise.
	IsDebugEnabled() bool
	// WithValues adapts the internal logger with a set of additional key/value
	// data
	WithValues(...interface{})
	// Debug writes a supplied log message about a resource that includes a set
	// of standard log values for the resource's kind, namespace, name, etc
	Debug(msg string, additionalValues ...interface{})
	// Info writes a supplied log message about a resource that includes a set
	// of standard log values for the resource's kind, namespace, name, etc
	Info(msg string, additionalValues ...interface{})
	// Enter logs an entry to a function or code block
	Enter(name string, additionalValues ...interface{})
	// Exit logs an exit from a function or code block
	Exit(name string, err error, additionalValues ...interface{})
	// Trace logs an entry to a function or code block and returns a functor
	// that can be called to log the exit of the function or code block
	Trace(name string, additionalValues ...interface{}) TraceExiter
}

Logger is responsible for writing log messages

var (
	// NoopLogger is useful for testing/mocking
	NoopLogger Logger = &voidLogger{}
)

func FromContext

func FromContext(ctx context.Context) Logger

FromContext returns a `Logger` from a saved key in the request context

type TraceExiter

type TraceExiter func(err error, additionalValues ...interface{})

TraceExiter demarcates the end of a traced code block or function

Jump to

Keyboard shortcuts

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