scope

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Overview

Package scope provides a scoped logger facade for telemetry.Logger implementations.

Index

Constants

View Source
const (
	// Key used to store the name of scope in the logger key/value pairs.
	Key = "scope"
)

Variables

View Source
var (

	// PanicOnUninitialized can be used when testing for sequencing issues
	// between creating log lines and initializing the actual logger
	// implementation to use.
	PanicOnUninitialized bool
)

Functions

func DefaultLevel

func DefaultLevel() telemetry.Level

DefaultLevel returns the logging level used for new scopes.

func List

func List() map[string]Scope

List all registered Scopes

func Names

func Names() []string

Names returns all registered scope names.

func PrintRegistered

func PrintRegistered()

PrintRegistered outputs a list of registered scopes with their log level on stdout.

func SetAllScopes

func SetAllScopes(lvl telemetry.Level)

SetAllScopes sets the logging level to all existing scopes and uses this level for new scopes.

func SetDefaultLevel

func SetDefaultLevel(lvl telemetry.Level)

SetDefaultLevel sets the default level used for new scopes.

func UseLogger

func UseLogger(logger telemetry.Logger)

UseLogger takes a logger and updates already registered scopes to use it. This function can only be used once. It can't override an already initialized logger. Therefore, set this as soon as possible.

Types

type CallerSkip added in v0.2.0

type CallerSkip interface {
	CSIncrease()
	CSDecrease()
}

type Scope

type Scope interface {
	telemetry.Logger

	// Name of the logging scope
	Name() string
	// Description of the logging scope
	Description() string
}

Scope configures a named logger that can be configured independently.

func Find

func Find(name string) (Scope, bool)

Find a scoped logger by its name.

func Register

func Register(name, description string) Scope

Register a new scoped Logger.

Jump to

Keyboard shortcuts

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