Documentation ¶
Overview ¶
Package logger is a simple wrapper around log.Logger with usual logging levels "error", "warning", "notice", "info" and "debug".
Index ¶
- Constants
- Variables
- func Debug(format string, v ...interface{})
- func Error(format string, v ...interface{})
- func Info(format string, v ...interface{})
- func Notice(format string, v ...interface{})
- func Warning(format string, v ...interface{})
- type FileConfig
- type Logger
- func (l *Logger) Close()
- func (l *Logger) Context(context string) *Logger
- func (l *Logger) CurrentContext() string
- func (l *Logger) Debug(format string, v ...interface{}) *Logger
- func (l *Logger) Error(format string, v ...interface{}) *Logger
- func (l *Logger) Info(format string, v ...interface{}) *Logger
- func (l *Logger) Logger(level int) *log.Logger
- func (l *Logger) Notice(format string, v ...interface{}) *Logger
- func (l *Logger) Warning(format string, v ...interface{}) *Logger
- type SyslogConfig
Constants ¶
const ( // LevelError represents the error logging level. LevelError // LevelWarning represents the warning logging level. LevelWarning // LevelNotice represents the notice logging level. LevelNotice // LevelInfo represents the info logging level. LevelInfo // LevelDebug represents the debug logging level. LevelDebug )
Variables ¶
var ( // ErrInvalidFacility represents an invalid syslog facility error. ErrInvalidFacility = errors.New("invalid syslog facility") // ErrInvalidLevel represents an invalid logging level error. ErrInvalidLevel = errors.New("invalid logging level") // ErrUnsupportedBackend represents an unsupported backend error. ErrUnsupportedBackend = errors.New("unsupported backend") )
Functions ¶
func Debug ¶
func Debug(format string, v ...interface{})
Debug prints a debug message using the default logger.
func Error ¶
func Error(format string, v ...interface{})
Error prints an error message using the default logger.
func Info ¶
func Info(format string, v ...interface{})
Info prints an information message using the default logger.
Types ¶
type FileConfig ¶
type FileConfig struct { // Logging output severity level. Messages with higher severity value will be discarded. Level string // File path of the logging output. If path is either empty or "-", logging will be output to os.Stderr. Path string }
FileConfig represents a file backend configuration.
type Logger ¶
Logger represents a logger instance.
func NewLogger ¶
NewLogger returns a new Logger instance initialized with the given configuration. If no configs are passed are parameter, log messages will effectively be discarded.
func (*Logger) Context ¶
Context clones the Logger instance and sets the context to the provided string.
func (*Logger) CurrentContext ¶
CurrentContext returns the current logger context.
type SyslogConfig ¶
type SyslogConfig struct { // Logging output severity level. Messages with higher severity value will be discarded. Level string // syslog facility to send messages to. Facility string // syslog tag to specify in messages. Tag string // syslog service address and transport type (either "udp", "tcp" or "unix"). If not sepcified, local syslog will // be used. Address string Transport string }
SyslogConfig represents a syslog backend configuration.