logger

package
v0.0.0-...-cc7cbc4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Overview

Package logger is responsible for logging.

Index

Constants

View Source
const (

	// FieldCtx is a key of logged context
	FieldCtx = "ctx"
)

Variables

This section is empty.

Functions

func New

func New(cfg *Config) *logrus.Entry

New creates new instance of logging apparatus. Logrus.Entry is returned as it's always decorated with fields.

Types

type Config

type Config struct {
	// Level sets the minimal logging level
	// values: debug, info (default), warn, warning, error, fatal, panic
	Level LogLevel `envconfig:"default=info"`

	// BuildHash holds hash of the git commit from which binary was build.
	BuildHash string `envconfig:"-"`
}

Config is responsible for configuring logger.

type Formatter

type Formatter struct{}

Formatter is a log formatter

func (*Formatter) Format

func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error)

Format formats log entry to adhere to YaaS specs

type LogLevel

type LogLevel logrus.Level

LogLevel is a config field type holding minimal log level. It's compatible with logrus level types.

func (*LogLevel) Unmarshal

func (m *LogLevel) Unmarshal(in string) error

Unmarshal provides custom parsing of Log Level. Implements envconfig.Unmarshal interface.

type THTimeForcedFormatter

type THTimeForcedFormatter struct {
	// OrigFormatter is an original formatter
	OrigFormatter logrus.Formatter

	// Time is a time to be forces in entries.
	Time time.Time
}

THTimeForcedFormatter is a Logrus compatible formatter which wraps original formatter and forces specific time. Designed to be used in testing.

func (*THTimeForcedFormatter) Format

func (f *THTimeForcedFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format entry but forces time for testing purposes

Directories

Path Synopsis
Package spy provides an implementation of go-sdk.logger that helps test logging.
Package spy provides an implementation of go-sdk.logger that helps test logging.

Jump to

Keyboard shortcuts

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