log

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int

Level indicates the severity of the data being logged.

const (
	// LevelCritical alerts about severe problems. Most of the time, needs some human intervention ASAP.
	LevelCritical Level = iota + 1
	// LevelError alerts about events that are likely to cause problems.
	LevelError
	// LevelWarning warns about events the might cause problems to the system.
	LevelWarning
	// LevelInfo are routine information.
	LevelInfo
	// LevelDebug are debug or trace information.
	LevelDebug
)

func (Level) String

func (l Level) String() string

String returns the name of the LogLevel.

type LogFormatter added in v0.2.3

type LogFormatter interface {
	// Format formats the log payload that will be rendered.
	Format(context.Context, format.LogInput) any
}

LogFormatter defines how structures that formats logs should behavior.

type Logger

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

Logger is the structure responsible for log data.

func NewLogger

func NewLogger(params LoggerParams) *Logger

NewLogger constructs a new Logger instance.

func (Logger) Critical

func (l Logger) Critical(ctx context.Context, err error)

Critical logs critical data. It increases error counter metrics.

func (Logger) Debug

func (l Logger) Debug(ctx context.Context, msg string, args ...interface{})

Debug logs debug data.

func (Logger) Error

func (l Logger) Error(ctx context.Context, err error)

Error logs error data. It increases error counter metrics.

func (Logger) Fatal added in v0.2.1

func (l Logger) Fatal(ctx context.Context, err error)

Fatal logs critical data and exists current program execution.

func (Logger) Info

func (l Logger) Info(ctx context.Context, msg string, args ...interface{})

Info logs info data.

func (Logger) JSON added in v0.4.0

func (l Logger) JSON(ctx context.Context, data any, logLevel ...Level)

JSON logs JSON data. By default, it logs with Debug level, but it can be overwritten with the optional logLevel parameter.

func (Logger) Warning

func (l Logger) Warning(ctx context.Context, msg string, args ...interface{})

Warning logs warning data.

type LoggerParams

type LoggerParams struct {
	Level      string
	Formatter  LogFormatter
	Attributes format.LogAttributeSet
}

LoggerParams defines the dependencies of a Logger.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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