debug

package
v1.5.14 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Debug

type Debug struct {
	// ComponentName is the component name.
	ComponentName string

	// OutputName is the output name.
	OutputName string

	// Content of the debug env var.
	Content string

	// Levels matcher regex matches against any valid level, specified at the
	// beginning of the debug env var, examples:
	// - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `info`
	// - SYPL_DEBUG="componentX:outputY:debug,outputZ:trace,info" -> “.
	//
	// Note: For this matcher, the order matter!
	Levels *regexp.Regexp

	// Output, and levels matcher regex matches against a specific output, and
	// any valid level specified in the debug env var, example:
	// - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `trace`
	OutputLevels *regexp.Regexp

	// COL matches against a specific component and output, and any valid level
	// specified in the debug env var, example:
	// - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `debug`.
	ComponentOutputLevels *regexp.Regexp
}

Debug definition.

func New

func New(componentName, outputName string) *Debug

New is the Debug factory.

func (*Debug) Level

func (d *Debug) Level() (level.Level, Matcher, bool)

Level checks the content of the debug env var against all matchers returning: - The level extracted from the last Matcher - The last `Matcher` that matched - If any matcher succeeded on matching

Matchers: - {componentName:outputName:level} -> forwarder:console:trace - {outputName:level} -> console:trace - {level}, e.g.: trace

Note: Don't use the returned level to check if `Level` succeeded because `level.None` is a valid, and usable level.

func (*Debug) MatchCOL

func (d *Debug) MatchCOL() string

MatchCOL uses the `ComponentOutputLevels` matcher against a specific component and output, and any valid level specified in the debug env var, example: - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `debug`.

Note: Prefer to use the `Level` method.

func (*Debug) MatchL

func (d *Debug) MatchL() string

MatchL uses the `Levels` matcher against any valid level, specified at the beginning of the debug env var, examples: - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `info` - SYPL_DEBUG="componentX:outputY:debug,outputZ:trace,info" -> “.

Notes: - For this matcher, the order matter! - Prefer to use the `Level` method.

func (*Debug) MatchOL

func (d *Debug) MatchOL() string

MatchOL uses the `OutputLevels` matcher against a specific output, and any valid level specified in the debug env var, example: - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `trace`

Note: Prefer to use the `Level` method.

type Matcher

type Matcher string
const (
	// L matches against any valid level, specified at the beginning of the
	// debug env var, examples:
	// - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `info`
	// - SYPL_DEBUG="componentX:outputY:debug,outputZ:trace,info" -> “.
	//
	// Note: For this matcher, the order matter!
	L Matcher = "Level"

	// OL matches against a specific output, and any valid level specified in
	// the debug env var, example:
	// - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `trace`.
	OL Matcher = "OutputLevel"

	// COL matches against a specific component and output, and any valid level
	// specified in the debug env var, example:
	// - SYPL_DEBUG="info,componentX:outputY:debug,outputZ:trace" -> `debug`.
	COL Matcher = "ComponentOutputLevel"

	// None means no Matcher matched against the debug env var.
	None Matcher = "None"
)

Jump to

Keyboard shortcuts

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