log

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

log

Documentation

Index

Constants

View Source
const (
	// LevelDebug provides the most verbose logging, allowing logs for debug, info,
	// warn, and error.
	LevelDebug Level = iota

	// LevelInfo is the default log level. It allows logs for info, warn, and
	// error.
	LevelInfo

	// LevelWarn is reserved for logging warnings and errors.
	LevelWarn

	// LevelError provides the least verbose logging, allowing logs only for
	// errors.
	LevelError

	// FormatJSON encodes each log entry as a single JSON object.
	FormatJSON Format = iota

	// FormatLogfmt encodes each log entry in logfmt format.
	FormatLogfmt

	// FormatNop will suppress logging output entirely.
	FormatNop
)

Variables

View Source
var (
	// ErrInvalidLevel will be returned when the level given to the WirhLevel
	// option is invalid.
	ErrInvalidLevel = errors.New("Invalid Level")

	// ErrInvalidFormat will be returned when the format given to the WithFormat
	// options is invalid.
	ErrInvalidFormat = errors.New("Invvalid Format")

	// ErrInvalidOutput will be returned when the output writer given to WithOuput
	// is nil.
	ErrInvalidOutput = errors.New("Invalid Format")
)

Functions

This section is empty.

Types

type Format

type Format uint

Format defines the output formats of the logger. Supported formats are FormatJSON (the default), FormatLogfmt, and FormatNop (no loggin).

type Level

type Level uint

Level defines the logging levels available to the Logger, with a level of debug logging all message and error logging only error message.

type Logger

type Logger interface {
	Debug(...interface{})
	Info(...interface{})
	Warn(...interface{})
	Error(...interface{})
}

Logger is the interface for all logging operations.

func New

func New(opts ...Option) (Logger, error)

New returns a Logger.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option provides for Logger configuration.

func WithFormat

func WithFormat(format Format) Option

WithFormat allows the format to be configured. The default format is FormatJSON.

func WithLevel

func WithLevel(level Level) Option

WithLevel allows the level to be configured. The default level is LevelInfo.

func WithOutput

func WithOutput(writer io.Writer) Option

WithOutput allows the format to be configured. The default writer is os.Stderr.

Jump to

Keyboard shortcuts

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