logging

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 4 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// Debug is the debug log level.
	Debug = "debug"
	// Info is the info(rmational) log level.
	Info = "info"
	// Critical is the critical log level.
	Critical = "critical"
)

Variables

This section is empty.

Functions

func DefaultFormatter added in v1.0.0

func DefaultFormatter(l, m string) string

DefaultFormatter is the default logging instance formatter -- this formatter simply adds colors to the log message based on log level.

func WithFormatter added in v1.0.0

func WithFormatter(f func(string, string) string) util.Option

WithFormatter sets the Formatter function of the logging instance.

func WithLevel added in v1.0.0

func WithLevel(s string) util.Option

WithLevel sets the logging level for a logging instance.

func WithLogger added in v1.0.0

func WithLogger(f func(...interface{})) util.Option

WithLogger appends a logger (a function that accepts an interface) to the Loggers slice of a logging instance.

Types

type Instance added in v1.0.0

type Instance struct {
	Level     string
	Formatter func(string, string) string
	Loggers   []func(...interface{})
}

Instance is a simple logging object.

func NewInstance added in v1.0.0

func NewInstance(opts ...util.Option) (*Instance, error)

NewInstance returns a new logging Instance.

func (*Instance) Critical added in v1.0.0

func (i *Instance) Critical(f string)

Critical accepts a Critical level log message with no formatting.

func (*Instance) Criticalf added in v1.0.0

func (i *Instance) Criticalf(f string, a ...interface{})

Criticalf accepts a Critical level log message normal fmt.Sprintf type formatting.

func (*Instance) Debug added in v1.0.0

func (i *Instance) Debug(f string)

Debug accepts a Debug level log message with no formatting.

func (*Instance) Debugf added in v1.0.0

func (i *Instance) Debugf(f string, a ...interface{})

Debugf accepts a Debug level log message normal fmt.Sprintf type formatting.

func (*Instance) Emit added in v1.0.0

func (i *Instance) Emit(m interface{})

Emit "emits" a logging message m to all the loggers in the Instance.

func (*Instance) Info added in v1.0.0

func (i *Instance) Info(f string)

Info accepts an Info level log message with no formatting.

func (*Instance) Infof added in v1.0.0

func (i *Instance) Infof(f string, a ...interface{})

Infof accepts an Info level log message normal fmt.Sprintf type formatting.

Jump to

Keyboard shortcuts

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