Documentation ¶
Index ¶
Constants ¶
View Source
const ( // LevelDebug provides the most verbose logging, allowing logs for debug, info, // warn, and error. LevelDebug Level = iota // LevelInfo is the default log level. It allows logs for info, warn, and // error. LevelInfo // LevelWarn is reserved for logging warnings and errors. LevelWarn // LevelError provides the least verbose logging, allowing logs only for // errors. LevelError // LevelInvalid indicates and invalid log level. LevelInvalid // FormatJSON encodes each log entry as a single JSON object. FormatJSON Format = iota // FormatLogfmt encodes each log entry in logfmt format. FormatLogfmt // FormatNop will suppress logging output entirely. FormatNop // FormatInvalid indicates an invalid log format. FormatInvalid )
Variables ¶
View Source
var ( // ErrInvalidLevel will be returned when the level given to the WirhLevel // option is invalid. ErrInvalidLevel = errors.New("Invalid Level") // ErrInvalidFormat will be returned when the format given to the WithFormat // options is invalid. ErrInvalidFormat = errors.New("Invvalid Format") // ErrInvalidOutput will be returned when the output writer given to WithOuput // is nil. ErrInvalidOutput = errors.New("Invalid Format") )
Functions ¶
Types ¶
type Format ¶ added in v0.8.0
type Format uint
Format defines the output formats of the logger. Supported formats are FormatJSON (the default), FormatLogfmt, and FormatNop (no loggin).
type Level ¶ added in v0.8.0
type Level uint
Level defines the logging levels available to the Logger, with a level of debug logging all message and error logging only error message.
type Logger ¶
type Logger interface { // Debug logs a debug level message. Debug(...interface{}) // Info logs an info level message. Info(...interface{}) // Warn logs a warn level message. Warn(...interface{}) // Error logs an error level message. Error(...interface{}) // With returns a new contextual logger with keyvals prepended to those // passed to calls to log. With(...interface{}) Logger }
Logger is the interface for all logging operations.
func LoggerFromContext ¶ added in v0.8.0
LoggerFromContext returns the logger for the current request.
type Option ¶ added in v0.8.0
type Option interface {
// contains filtered or unexported methods
}
Option provides for Logger configuration.
func WithFormat ¶ added in v0.8.0
WithFormat allows the format to be configured. The default format is FormatJSON.
func WithLevel ¶ added in v0.8.0
WithLevel allows the level to be configured. The default level is LevelInfo.
func WithOutput ¶ added in v0.8.0
WithOutput allows the format to be configured. The default writer is os.Stderr.
Click to show internal directories.
Click to hide internal directories.