log

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debugf

func Debugf(format string, args ...interface{})

func Errorf

func Errorf(format string, args ...interface{})

func Infof

func Infof(format string, args ...interface{})

func InitDefaultLogger

func InitDefaultLogger(opts ...LoggerOption)

func Warnf

func Warnf(format string, args ...interface{})

Types

type Format

type Format string

Format represents the logging format.

const (
	// FormatJSON represents a JSON format.
	FormatJSON Format = "json"

	// FormatJSON represents a text format.
	FormatText Format = "text"
)

type Level

type Level uint32

Level represents the logging level.

const (
	// Usually only enabled when debugging. Very verbose logging.
	LevelDebug Level = iota

	// General operational entries about what's going on inside the application.
	LevelInfo

	// Non-critical events that should be looked at.
	LevelWarn

	// Critical events that require immediate attention.
	LevelError
)

type Logger

type Logger interface {
	// Debug logs a Debug event.
	Debugf(format string, args ...interface{})

	// Info logs an Info event.
	Infof(format string, args ...interface{})

	// Warn logs a Warn(ing) event.
	Warnf(format string, args ...interface{})

	// Error logs an Error event.
	Errorf(format string, args ...interface{})
}

Logger is a unified interface for logging.

func NewLogrusLogger

func NewLogrusLogger(options ...LoggerOption) Logger

type LoggerOption

type LoggerOption func(*LoggerOptions)

LoggerOption sets an optional parameter for loggers.

func WithFormat

func WithFormat(format Format) LoggerOption

WithFormat sets the logger format.

func WithLevel

func WithLevel(level Level) LoggerOption

WithLevel sets the logger verbosity level.

func WithOutput

func WithOutput(out io.Writer) LoggerOption

WithOutput sets the logger output.

type LoggerOptions

type LoggerOptions struct {
	// Out specifies the output data stream.
	Out io.Writer

	// Level specifies the logging level the logger should log at. This is
	// typically (and defaults to) `Info`, which allows Info(), Warn() and
	// Error() to be logged.
	Level Level

	// Format specifies the logging format the logger should log at.
	Format Format
}

Jump to

Keyboard shortcuts

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