logging

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 4 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoLogger bark.Logger = noLogger{}

NoLogger is the default logger used by logging facilities when a logger is not passed.

Functions

func Logger

func Logger(logName string) bark.Logger

Logger returns a named logger from the default facility.

func SetLevel

func SetLevel(logName string, level Level) error

SetLevel sets the severity level for a named logger on the default facility.

func SetLevels

func SetLevels(levels map[string]Level) error

SetLevels same as SetLevels but for multiple named loggers.

func SetLogger

func SetLogger(log bark.Logger)

SetLogger sets the underlying logger for the default facility.

Types

type Facility

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

Facility is a collection of named loggers that can be configured individually.

func NewFacility

func NewFacility(log bark.Logger) *Facility

NewFacility creates a new log facility with the specified logger as the underlying logger. If no logger is passed, a no-op implementation is used.

func (*Facility) Log

func (f *Facility) Log(logName string, wantLevel Level, fields bark.Fields, msg []interface{})

Log logs messages with a severity level equal to or higher than the one set with SetLevel. If that's not the case, the message is silenced. If the logName was not previously configured with SetLevel, the messages are never silenced. Instead on using this method directly, one can call Logger method to get a bark.Logger instance bound to a specific name.

func (*Facility) Logf

func (f *Facility) Logf(logName string, wantLevel Level, fields bark.Fields, format string, msg []interface{})

Logf is the same as Log but with fmt.Printf-like formatting

func (*Facility) Logger

func (f *Facility) Logger(logName string) bark.Logger

Logger returns a new named logger.

func (*Facility) SetLevel

func (f *Facility) SetLevel(logName string, level Level) error

SetLevel sets the minimum severity level for a named logger. All messages produced by a named logger with a severity lower than the one set here are silenced. In most logger implementations, both Fatal and Panic stop the execution. This means that those levels only produce a single, and often important, message. Because of that, it's an error to pass a level above Fatal to this method.

func (*Facility) SetLevels

func (f *Facility) SetLevels(levels map[string]Level) error

SetLevels is like SetLevel but for multiple named loggers.

func (*Facility) SetLogger

func (f *Facility) SetLogger(log bark.Logger)

SetLogger sets the underlying logger. All log messages produced, that are not silenced, are propagated to this logger.

type Level

type Level uint8

Level is the severity level of a log message.

const (
	// Panic log level
	Panic Level = iota
	// Fatal log level
	Fatal
	// Error log level
	Error
	// Warn log level
	Warn
	// Info log level
	Info
	// Debug log level
	Debug
)

Additional levels can be created from integers between Debug and maxLevel.

func Parse

func Parse(lvl string) (Level, error)

Parse converts a string to a log level.

func (Level) String

func (lvl Level) String() string

String converts a log level to its string representation.

Jump to

Keyboard shortcuts

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