scope

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 9 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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()
}

CallerSkip interface can be implemented by loggers to adjust the caller skip level when used in a scope.

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