Documentation ¶
Index ¶
- Variables
- func Debugf(msg string, v ...interface{})
- func Errorf(msg string, v ...interface{})
- func Infof(msg string, v ...interface{})
- func Tracef(msg string, v ...interface{})
- func Warnf(msg string, v ...interface{})
- type ContextConfig
- type ContextLager
- func Child() ContextLager
- func NewContextLager(config *ContextConfig) ContextLager
- func Set(key, value string) ContextLager
- func SetDrinker(drinker Drinker) ContextLager
- func SetFileType(fileType FileType) ContextLager
- func SetLevels(levels *Levels) ContextLager
- func SetStacktraces(on bool) ContextLager
- func With(fields map[string]string) ContextLager
- func WithError(err error) ContextLager
- type Drinker
- type FileType
- type JSONDrinker
- type Lager
- type Level
- type Levels
- type LogConfig
- type LogDrinker
- type LogLager
- type NewDrinkerFunc
Constants ¶
This section is empty.
Variables ¶
var ErrNoDrinker = errors.New("No Drinker")
ErrNoDrinker is used when a drinker cannot be returned, primarly DrinkerFromString
Functions ¶
func Debugf ¶
func Debugf(msg string, v ...interface{})
Debugf logs with level Debug using the package lager.
func Errorf ¶
func Errorf(msg string, v ...interface{})
Errorf logs with level Error using the package lager.
func Infof ¶
func Infof(msg string, v ...interface{})
Infof logs with level Info using the package lager.
Types ¶
type ContextConfig ¶
type ContextConfig struct { Levels *Levels Drinker Drinker Values map[string]string Stacktraces bool FileType FileType }
ContextConfig is defines the configuration for ContextLager.
func DefaultContextConfig ¶
func DefaultContextConfig() *ContextConfig
DefaultContextConfig creates a default ContextConfig
type ContextLager ¶
type ContextLager interface { Lager With(map[string]string) ContextLager WithError(error) ContextLager Set(key, value string) ContextLager Child() ContextLager }
ContextLager is a Lager that adds context to logs with key value pairs
func Child ¶
func Child() ContextLager
Child creates a child ContextLager using the package lager as the parent. The child inherits all the parent values.
func NewContextLager ¶
func NewContextLager(config *ContextConfig) ContextLager
NewContextLager creates a JSONLager
func Set ¶
func Set(key, value string) ContextLager
Set sets a key to value in the lager map using the package lager.
func SetDrinker ¶
func SetDrinker(drinker Drinker) ContextLager
SetDrinker sets the drinker of the package lager.
func SetFileType ¶
func SetFileType(fileType FileType) ContextLager
SetFileType sets the fileType that is used for logs.
func SetLevels ¶
func SetLevels(levels *Levels) ContextLager
SetLevels sets the levels of the package lager.
func SetStacktraces ¶
func SetStacktraces(on bool) ContextLager
SetStacktraces sets whether stacktraces are captured on error.
func With ¶
func With(fields map[string]string) ContextLager
With adds key values to the returned lager using the package lager.
func WithError ¶
func WithError(err error) ContextLager
WithError adds an error key value to the returned lager if non nil, using the package lager.
type Drinker ¶
Drinker will drink logs and output them
func NewJSONDrinker ¶
NewJSONDrinker creates a new JSON Drinker
func NewLogDrinker ¶
NewLogDrinker creates a new Log Drinker
type FileType ¶
type FileType uint8
FileType represents values for including file information of logs
const ( // NoFile does not include the file name or line number of the log NoFile FileType = iota // ShortFile includes the file name and line number of the log ShortFile // PackageFile includes the file name, including package, and line number of the log PackageFile // FullFile includes the absolute file path and line number of the log FullFile )
type JSONDrinker ¶
type JSONDrinker struct {
// contains filtered or unexported fields
}
JSONDrinker Drinks logs by outputting them to JSON
func (*JSONDrinker) Drink ¶
func (drkr *JSONDrinker) Drink(v map[string]interface{}) error
Drink drinks logs
type Lager ¶
type Lager interface { Tracef(msg string, v ...interface{}) Debugf(msg string, v ...interface{}) Infof(msg string, v ...interface{}) Warnf(msg string, v ...interface{}) Errorf(msg string, v ...interface{}) SetLevels(levels *Levels) Levels() *Levels }
Lager is a Lager that explicitly defines all of the log levels as log methods.
type Levels ¶
type Levels struct {
// contains filtered or unexported fields
}
Levels contains the log levels a logger will write to a Drinker
func LevelsFromString ¶
LevelsFromString creates a levels object from a string Levels are specified using a capital letter corresponding to the first level of the desired level.
type LogDrinker ¶
type LogDrinker struct {
// contains filtered or unexported fields
}
LogDrinker is a Drinker that uses log.Logger
func (*LogDrinker) Drink ¶
func (drkr *LogDrinker) Drink(v map[string]interface{}) error
Drink drinks logs
type LogLager ¶
type LogLager struct { Lager // contains filtered or unexported fields }
LogLager implements Logger using *log.Logger
type NewDrinkerFunc ¶
NewDrinkerFunc creates a new drinker
func DrinkerFromString ¶
func DrinkerFromString(str string) (NewDrinkerFunc, error)
DrinkerFromString provides a way to get a NewDrinkerFunc using a string. Useful for deciding on a Drinker using the environment.