Documentation
¶
Overview ¶
Package log provides utilities for logging messages to various outputs.
Index ¶
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) NewLogger ¶
NewLogger initiates and returns a new logger with the target Backend as output.
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 Formatter ¶ added in v1.2.0
Formatter is the types of the functions that can be used to format a log entry. They take a pointer to a record and return a formatted string.
type Level ¶
type Level uint8
Level represents a logging level. Available levels are: - LevelDebug - LevelInfo - LevelNotice - LevelWarning - LevelError - LevelCritical - LevelAlert - LevelFatal.
const ( LevelTrace Level LevelDebug LevelInfo LevelNotice LevelWarning LevelError LevelCritical LevelAlert LevelFatal )
type Logger ¶
Logger is an internal abstraction of the underlying logging library.
Source Files
¶
- backend.go
- backend_pool.go
- format.go
- level.go
- level_string.go
- logger.go
- syslog_unix.go