Documentation ¶
Overview ¶
Package log provides utilities for logging messages to various outputs.
Index ¶
- Constants
- type Backend
- type BackendPool
- type Level
- type Logger
- func (l *Logger) Alert(msg string, args ...any)
- func (l *Logger) AsStdLogger(level Level) *log.Logger
- func (l *Logger) Critical(msg string, args ...any)
- func (l *Logger) Debug(msg string, args ...any)
- func (l *Logger) Error(msg string, args ...any)
- func (l *Logger) Fatal(msg string, args ...any)
- func (l *Logger) Info(msg string, args ...any)
- func (l *Logger) Notice(msg string, args ...any)
- func (l *Logger) Trace(msg string, args ...any)
- func (l *Logger) Warning(msg string, args ...any)
Constants ¶
const ( Stdout = "stdout" Stderr = "stderr" Discard = "discard" Syslog = "syslog" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func NewBackend ¶
NewBackend initializes the logging backend according to the given configuration. If the backend cannot be accessed, an error is returned.
Level represents the minimum logging priority accepted by the backend. Any message with a lower priority will be discarded.
LogTo is the logging output. It can be either: - Stdout - Stderr - Discard - Syslog - a file name
Facility and Tag are only used with a Syslog output. They represent respectively the logging facility and the application's name (in the logging facility).
func (*Backend) ChangeLevel ¶
type BackendPool ¶ added in v1.1.0
type BackendPool struct {
// contains filtered or unexported fields
}
BackendPool represent a pool of backends. When instantiating a Logger from a pool of backend, any message written to this Logger will be written to all to backends from the pool. This can be useful if one wishes to send log messages to different outputs depending on the message's level.
func (*BackendPool) AddBackend ¶ added in v1.1.0
func (b *BackendPool) AddBackend(back *Backend)
AddBackend adds a backend to the pool.
func (*BackendPool) NewLogger ¶ added in v1.1.0
func (b *BackendPool) NewLogger(name string) *Logger
NewLogger initiates and returns a new logger with all the pool's backends as output.
type Level ¶
type Level uint8
Level represents a logging level. Available levels are: - LevelDebug - LevelInfo - LevelWarning - LevelError - LevelCritical.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an internal abstraction of the underlying logging library.
func (*Logger) AsStdLogger ¶ added in v1.1.0
AsStdLogger returns an instance of the standard log.Logger. Any messages written to this standard logger will be written to the source logger with the given level.
func (*Logger) Critical ¶
Critical outputs a log message at the "critical" (LevelCritical) priority.
func (*Logger) Fatal ¶
Fatal outputs a log message at the "fatal" (LevelFatal) priority, and immediately exits the program afterwards.