Documentation ¶
Overview ¶
Package clogger provides a Logger interface that can be used to log messages and errors
Index ¶
Constants ¶
const ( FormatPlain = Format("plain") FormatJSON = Format("json") )
Formats supported by Logger
const ( LevelDebug = Level(iota + 1) LevelInfo LevelWarn LevelError )
Pre-defined log levels.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.0
type Config struct { Out string `toml:"out"` Err string `toml:"err"` Format Format `toml:"format"` }
Config holds the params needed to configure Logger
type Format ¶ added in v0.2.0
type Format string
Format represents the output format of log statements
type Logger ¶
type Logger interface { WithTags(tags map[string]interface{}) Logger Debug(msg string) Info(msg string) Warn(msg string, err error) Error(msg string, err error) }
Logger can be used to log messages and errors.
func NewNoop ¶
func NewNoop() Logger
NewNoop returns a no-op implementation of Logger. Useful in passing it as a valid logger in unit tests.
func NewRecorder ¶
func NewRecorder(logs *[]RecordedLog) Logger
NewRecorder returns an implementation of Logger that keeps a record of each log. Useful in unit tests when logs need to be tested.
func NewWithConfig ¶
NewWithConfig creates a Logger based on the provided config.
func NewWithWriters ¶
NewWithWriters creates a Logger that uses the provided writers. out is used for debug and info levels. err is used for warn and error levels.
func NewZapLogger ¶ added in v0.4.0
func NewZapLogger(config Config, lc *clifecycle.Lifecycle) (Logger, error)
NewZapLogger creates a Logger that internally uses go.uber.org/zap for logging