Documentation ¶
Overview ¶
Package logger adapts log.Logger with Log and Logf funcs.
There are two benefits of this, the smaller Logger interface limits logging to output only and can easily be replaced by the testing.T object during testing.
type Car struct { logger.Logger } car := &Car{logger.New()} car.Log("brakes are failing") car.Logf("reached speed limit %s", 100)
Example (Silent) ¶
package main import ( "github.com/gregoryv/logger" ) func main() { l := logger.Silent l.Log("nada") l.Logf("%s", "nada") }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface { Log(args ...interface{}) Logf(format string, args ...interface{}) }
var Silent Logger = silent(0)
Logger that outputs nothing
type Wrapped ¶
type Wrapped struct {
// contains filtered or unexported fields
}
func New ¶
func New() *Wrapped
Returns a logger with log.LstdFlags|log.Lshortfile that writes to stderr
Example ¶
package main import ( "github.com/gregoryv/logger" ) func main() { type Car struct { logger.Logger } car := &Car{logger.New()} car.Log("brakes are failing") car.Logf("reached speed limit %v", 100) }
Output:
func NewProgress ¶
func NewProgress() *Wrapped
Returns a logger with empty flags that writes to stdout
Click to show internal directories.
Click to hide internal directories.