Go core-like logger with levels and default logger
Go
Latest commit 9c7ea0f Dec 5, 2014 @tj tj add Fatalf()
Permalink
Failed to load latest commit information.
History.md Release v1.8.0 Oct 6, 2014
Readme.md Add missing ")" Nov 10, 2014
log.go add Fatalf() Dec 5, 2014
log_test.go expose std singleton as .Log Sep 29, 2014
std.go add Fatalf() Dec 5, 2014

Readme.md

go-log

Simple printf-style logger which is more or less the same as Go's core logger with log levels.

View the docs.

Example

log.Debug("something")
log.Emergency("hello %s %s", "tobi", "ferret")

l := log.New(os.Stderr, log.DEBUG, "")
l.Debug("something happened")
l.Info("hello %s", "Tobi")
l.Error("boom something exploded")

Conventions

Typically you'll want to "inherit" from a parent logger, this allows for setting changes at the root of your application to trickle down.

To do this you can use Logger.New(prefix string), for example here a child logger is created by calling .New() on the standard logger:

var log = log.Log.New("mylib")

License

MIT