log

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package log configuration

Index

Constants

View Source
const (
	LoggerField = "logger"

	FieldStack = "stack"

	FieldTemplateLoader  = "template_loader"
	FieldTemplateName    = "template_name"
	FieldTemplatePart    = "template_part"
	FieldTemplateType    = "template_type"
	FieldTemplateDir     = "template_dir"
	FieldTemplatePath    = "template_path"
	FieldCallbackType    = "event_type"
	FieldTemplateExample = "template_example"

	FieldDocumentID  = "document_id"
	FieldContentType = "content_type"
	FieldAssetPath   = "asset_path"

	FieldListenAddr  = "listen_addr"
	FieldDocumentURL = "document_url"

	FieldBrowserReply = "browser_reply"
	FieldBrowserEvent = "browser_event"
	FieldBrowserOut   = "browser_out"
	FieldBrowserState = "browser_state"
	FieldBrowserData  = "browser_data"

	FieldRenderDataErrors = "render_data_errors"
	FieldRenderData       = "render_data"

	FieldConfig = "config"

	FieldDuration = "duration"

	FieldRequestID     = "request_id"
	FieldRequestIP     = "addr"
	FieldRequestMethod = "method"
	FieldRequestPath   = "path"
	FieldRequestRoute  = "route"
	FieldRequestQuery  = "query"

	FieldResponseCode = "response_code"
	FieldResponseSize = "response_size"
)

Logger fields.

View Source
const (
	LevelTrace = Level(logrus.TraceLevel)
	LevelDebug = Level(logrus.DebugLevel)
	LevelInfo  = Level(logrus.InfoLevel)
	LevelWarn  = Level(logrus.WarnLevel)
	LevelError = Level(logrus.ErrorLevel)
	LevelFatal = Level(logrus.FatalLevel)
)

Logger levels.

View Source
const (
	TextFormat = Format("text")
	JSONFormat = Format("json")
)

Definition of available log formats.

View Source
const (
	ContextKeyRequestID = contextKey("requestID")
)

Context keys.

Variables

This section is empty.

Functions

func ContextWithLogger

func ContextWithLogger(ctx context.Context, logger Logger) context.Context

ContextWithLogger create new context with logger.

func NewLogger

func NewLogger(level Level, format Format) *logrus.Logger

NewLogger with selected level.

func NewLoggerFromConfig added in v0.9.0

func NewLoggerFromConfig(config Config) *logrus.Logger

NewLoggerFromConfig constructor.

func WithLoggerFields added in v0.9.1

func WithLoggerFields(ctx context.Context, fields logrus.Fields) context.Context

WithLoggerFields create new context with logger with fields.

Types

type Config added in v0.9.0

type Config struct {
	Level  Level
	Format Format
}

Config defines the configuration of the logger.

func DefaultConfig added in v0.9.0

func DefaultConfig() Config

DefaultConfig returns the default config.

func (*Config) BindFlags added in v0.9.0

func (config *Config) BindFlags() []cli.Flag

BindFlags binds the flags to the config.

type Duration

type Duration time.Duration

Duration used to wrap time.Duration value to log only seconds.

func (Duration) String

func (duration Duration) String() string

String return test representation of Duration for logging value.

type Format

type Format string

Format text or json.

func AvailableFormats

func AvailableFormats() []Format

AvailableFormats return list all available log formats.

func (*Format) Set

func (format *Format) Set(value string) error

Set parse log format value on parsing cli arguments.

func (Format) String

func (format Format) String() string

type Level

type Level logrus.Level

Level is logrus.Level wrapper with support flag.Value interface.

func AvailableLevels

func AvailableLevels() []Level

AvailableLevels return all available log levels.

func (*Level) Set

func (ll *Level) Set(s string) error

Set implement flag.Value.Set interface.

func (Level) String

func (ll Level) String() string

type Logger

type Logger logrus.FieldLogger

Logger interface.

func LoggerFromContext

func LoggerFromContext(ctx context.Context, loggerName string) Logger

LoggerFromContext fetch logger from context.

type UnknownFormatError

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

UnknownFormatError return by LogFormat.Set when provided unknown format.

func NewUnknownFormatError

func NewUnknownFormatError(value string) *UnknownFormatError

NewUnknownFormatError constructor.

func (*UnknownFormatError) Error

func (err *UnknownFormatError) Error() string

Jump to

Keyboard shortcuts

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