logr

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLogger

func WithLogger(ctx context.Context, l Logger) context.Context

func WithLoggerContext

func WithLoggerContext(l Logger) contextx.WithContext

Types

type Level

type Level uint32

Level type

const (
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel Level = iota
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
)

func ParseLevel

func ParseLevel(lvl string) (Level, error)

ParseLevel takes a string level and returns the Logrus log level constant.

func (Level) MarshalText

func (lvl Level) MarshalText() ([]byte, error)

func (Level) String

func (lvl Level) String() string

func (*Level) UnmarshalText

func (lvl *Level) UnmarshalText(text []byte) error

type Logger

type Logger interface {
	// Start to start span for tracing
	//
	// 	ctx log = log.Start(ctx, "SpanName")
	// 	defer log.End()
	//
	Start(context.Context, string, ...any) (context.Context, Logger)
	// End to end span
	End()

	// WithValues key value pairs
	WithValues(keyAndValues ...interface{}) Logger

	Debug(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Warn(err error)
	Error(err error)
}

func Discard

func Discard() Logger

func FromContext

func FromContext(ctx context.Context) Logger

func Start

func Start(ctx context.Context, name string, kvs ...any) (context.Context, Logger)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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