Documentation ¶
Overview ¶
Package fox provides loggers implementing the simple fox.Logger interface. The fox.Logger interface matches that of testing.T.Log method which makes it very easy to inject during testing.
Example usage ¶
Use the Log method as a first class citizen
Log := fox.NewSyncLog(os.Stdout).Log Log("some", "nice", "message")
and warnings are simplified by filtering out empty values
warn := fox.NewSyncLog(os.Stdout).FilterEmpty().Log warn("") // will not be logged // Log errors only if there are any warn(nil) // nothing, it's nil warn(io.EOF)
Wrap the standard log package and it's default logger
Log := fox.LoggerFunc(log.Println) Log("hello", "standard", "logger")
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterEmpty ¶
type FilterEmpty struct {
// contains filtered or unexported fields
}
func NewFilterEmpty ¶
func NewFilterEmpty(l Logger) *FilterEmpty
NewFilterEmpty wraps the given logger with a filter for empty values.
func (*FilterEmpty) Log ¶
func (l *FilterEmpty) Log(v ...interface{})
Log calls the underlying logger only if v is non empty
Example ¶
Log := NewSyncLog(os.Stdout).FilterEmpty().Log Log("hey") Log(nil) Log("") Log("there")
Output: hey there
type Logger ¶
type Logger interface {
Log(...interface{})
}
var NoLogger Logger = LoggerFunc(func(v ...interface{}) {})
type LoggerFunc ¶
type LoggerFunc func(...interface{})
func (LoggerFunc) Log ¶
func (me LoggerFunc) Log(args ...interface{})
Example ¶
log.SetFlags(0) log.SetOutput(os.Stdout) std := LoggerFunc(log.Println) std.Log("hello", "fox")
Output: hello fox
type Logging ¶ added in v0.6.0
type Logging struct {
Logger
}
Logging implements github.com/gregoryv/ant Setting interface
type SyncLog ¶
type SyncLog struct {
// contains filtered or unexported fields
}
func NewSyncLog ¶
func (*SyncLog) FilterEmpty ¶
func (l *SyncLog) FilterEmpty() *FilterEmpty
FilterEmpty returns a wrapper filtering out empty and nil values
Click to show internal directories.
Click to hide internal directories.