log

package
v0.259.3 Latest Latest
Warning

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

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

Documentation

Overview

Package log provides a logging interface to send logs from plugins to Grafana server.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = New()

DefaultLogger is the default logger.

Functions

func ContextualAttributesFromContext added in v0.186.0

func ContextualAttributesFromContext(ctx context.Context) []any

ContextualAttributesFromContext returns the contextual key/value log parameters from the given context. If no contextual log parameters are set, it returns nil.

func ContextualAttributesFromIncomingContext added in v0.244.0

func ContextualAttributesFromIncomingContext(ctx context.Context) []any

ContextualAttributesFromIncomingContext returns the contextual key/value log parameters from the given incoming context.

func WithContextualAttributes added in v0.186.0

func WithContextualAttributes(ctx context.Context, logParams []any) context.Context

WithContextualAttributes returns a new context with the given key/value log parameters appended to the existing ones. It's possible to get a logger with those contextual parameters by using [FromContext].

func WithContextualAttributesForOutgoingContext added in v0.244.0

func WithContextualAttributesForOutgoingContext(ctx context.Context, logParams []any) context.Context

WithContextualAttributesForOutgoingContext will append the given key/value log parameters to the outgoing context.

Types

type Level added in v0.124.0

type Level int32
const (
	NoLevel Level = iota
	Trace
	Debug
	Info
	Warn
	Error
)

type Logger

type Logger interface {
	Debug(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Warn(msg string, args ...interface{})
	Error(msg string, args ...interface{})
	With(args ...interface{}) Logger
	Level() Level
	FromContext(ctx context.Context) Logger
}

Logger is the main Logger interface.

func New

func New() Logger

New creates a new logger.

func NewNullLogger added in v0.203.0

func NewNullLogger() Logger

NewNullLogger returns a logger that does nothing, for testing purposes

func NewWithLevel added in v0.124.0

func NewWithLevel(level Level) Logger

NewWithLevel creates a new logger at the Level defined.

Jump to

Keyboard shortcuts

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