logger

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: Apache-2.0 Imports: 11 Imported by: 2

README

Telemetry Go kit Log

This package contains a Telemetry Logger interface compatible implementation based on Go kit log.

For information on the Telemetry Logger interface, see: https://github.com/tetratelabs/telemetry

For more information on how to use this specific package, see: https://pkg.go.dev/github.com/tetratelabs/telemetry-gokit-log

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level added in v0.2.0

type Level int32

Level is an enumeration of the available log levels.

const (
	None  Level = 0
	Error Level = 1
	Info  Level = 5
	Debug Level = 10
)

Available log levels.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger implements the telemetry.Logger interface using Go kit Log.

func New

func New(logger log.Logger) *Logger

New returns a new telemetry.Logger implementation based on Go kit log.

func NewSyncLogfmt added in v0.2.0

func NewSyncLogfmt(w io.Writer) *Logger

NewSyncLogfmt returns a new telemetry.Logger implementation using Go kit's sync writer and logfmt output format.

func (*Logger) Context

func (l *Logger) Context(ctx context.Context) telemetry.Logger

Context attaches provided Context to the Logger allowing metadata found in this context to be used for log lines and metrics labels.

func (*Logger) Debug

func (l *Logger) Debug(msg string, keyValues ...interface{})

Debug logging with key-value pairs. Don't be shy, use it.

func (*Logger) Error

func (l *Logger) Error(msg string, err error, keyValues ...interface{})

Error logging with key-value pairs. Use this when application state and stability are at risk. These types of conditions are actionable and often alerted on. It is very strongly encouraged to add a Metric to each of these types of messages. Metrics provide the easiest way to coordinate processing of these concerns and triggering alerting systems through your metrics backend.

func (*Logger) Info

func (l *Logger) Info(msg string, keyValues ...interface{})

Info logging with key-value pairs. This is for informational, but not directly actionable conditions. It is highly recommended you attach a Metric to these types of messages. Where a single informational or warning style message might not be reason for action, a change in occurrence does warrant action. By attaching a Metric for these logging situations, you make this easy through histograms, thresholds, etc.

func (*Logger) Metric

func (l *Logger) Metric(m telemetry.Metric) telemetry.Logger

Metric attaches provided Metric to the Logger allowing this metric to record each invocation of Info and Error log lines. If context is available in the logger, it can be used for Metrics labels.

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl Level)

SetLevel provides the ability to set the desired logging level. This function can be used at runtime and is safe for concurrent use.

func (*Logger) With

func (l *Logger) With(keyValues ...interface{}) telemetry.Logger

With returns Logger with provided key value pairs attached.

type ScopeManager added in v0.2.0

type ScopeManager struct {
	// contains filtered or unexported fields
}

ScopeManager manages scoped loggers.

func NewScopeManager added in v0.2.0

func NewScopeManager(logger *Logger) *ScopeManager

NewScopeManager returns a new Scope Manager for Logger.

func (*ScopeManager) Deregister added in v0.2.0

func (s *ScopeManager) Deregister(name string) bool

Deregister will attempt to deregister a scoped Logger identified by the provided name. If the logger was found, the function returns true.

func (*ScopeManager) FlagSet added in v0.2.0

func (s *ScopeManager) FlagSet() *run.FlagSet

FlagSet implements run.Config.

func (*ScopeManager) GetDefaultOutputLevel added in v0.2.0

func (s *ScopeManager) GetDefaultOutputLevel() Level

GetDefaultOutputLevel returns the default minimum output level for scopes.

func (*ScopeManager) GetOutputLevel added in v0.2.0

func (s *ScopeManager) GetOutputLevel(name string) (Level, error)

GetOutputLevel returns the minimum log output level for a given scope.

func (*ScopeManager) Name added in v0.2.0

func (s *ScopeManager) Name() string

Name implements run.Unit.

func (*ScopeManager) PrintRegisteredScopes added in v0.2.0

func (s *ScopeManager) PrintRegisteredScopes()

PrintRegisteredScopes logs all the registered scopes and their configured output levels.

func (*ScopeManager) Register added in v0.2.0

func (s *ScopeManager) Register(name, description string) *Logger

Register takes a name and description and returns a scoped Logger.

func (*ScopeManager) SetDefaultOutputLevel added in v0.2.0

func (s *ScopeManager) SetDefaultOutputLevel(lvl Level)

SetDefaultOutputLevel sets the minimum log output level for all scopes.

func (*ScopeManager) SetScopeOutputLevel added in v0.2.0

func (s *ScopeManager) SetScopeOutputLevel(name string, lvl Level) error

SetScopeOutputLevel sets the minimum log output level for a given scope.

func (*ScopeManager) Validate added in v0.2.0

func (s *ScopeManager) Validate() error

Validate implements run.Config.

Directories

Path Synopsis
group module

Jump to

Keyboard shortcuts

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