logging

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Level:  LevelDefault,
	Format: FormatDefault,
}

DefaultOptions holds defaults for creating a Logger.

Functions

This section is empty.

Types

type Format

type Format string

Format represents a text format to use when writing logs.

const (
	FormatLogfmt Format = "logfmt"
	FormatJSON   Format = "json"

	FormatDefault = FormatLogfmt
)

Supported log formats.

func (Format) MarshalText

func (ll Format) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler.

func (*Format) UnmarshalText

func (ll *Format) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Level

type Level string

Level represents how verbose logging should be.

const (
	LevelDebug Level = "debug"
	LevelInfo  Level = "info"
	LevelWarn  Level = "warn"
	LevelError Level = "error"

	LevelDefault = LevelInfo
)

Supported log levels

func (Level) Filter

func (ll Level) Filter() level.Option

Filter returns a go-kit logging filter from the level.

func (Level) MarshalText

func (ll Level) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler.

func (*Level) UnmarshalText

func (ll *Level) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Logger

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

Logger implements the github.com/go-kit/log.Logger interface. It supports being dynamically updated at runtime.

func New

func New(w io.Writer, o Options) (*Logger, error)

New creates a New logger with the default log level and format.

func (*Logger) Log

func (l *Logger) Log(kvps ...interface{}) error

Log implements log.Logger.

func (*Logger) Update

func (l *Logger) Update(o Options) error

Update re-configures the options used for the logger.

type Options

type Options struct {
	Level  Level  `river:"level,attr,optional"`
	Format Format `river:"format,attr,optional"`
}

Options is a set of options used to construct and configure a Logger.

func (*Options) SetToDefault added in v0.35.0

func (o *Options) SetToDefault()

SetToDefault implements river.Defaulter.

Jump to

Keyboard shortcuts

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