lgr - simple logger with some extras

install
go get github.com/go-pkgz/lgr
usage
l := lgr.New(lgr.Debug, lgr.CallerFile) // allow debug and caller file info
l.Logf("INFO some important message, %v", err)
l.Logf("DEBUG some less important message, %v", err)
output looks like this:
2018/01/07 13:02:34.000 INFO {svc/handler.go:101 h.MyFunc1} some important message, can't open file`
2018/01/07 13:02:34.015 DEBUG {svc/handler.go:155 h.MyFunc2} some less important message, file is too small`
Without lgr.Caller* it will drop {caller} part
details
interfaces and default loggers
lgrpackage provides a single interfacelgr.Lwith a single methodLogf(format string, args ...interface{}). Function wrapperlgr.Funcallows to makelgr.Lfrom a function directly.- Default logger functionality can be used without
lgr.New, but justlgr.Printf - Two predefined loggers available:
lgr.NoOp(do-nothing logger) andlgr.Std(passing directly to stdlib log)
options
lgr.New call accepts functional options:
lgr.Debug- turn debug mode on to allow messages with "DEBUG" level (filtered overwise)lgr.CallerFile- adds the caller file infolgr.CallerFunc- adds the caller function infolgr.CallerPkg- adds the caller packagelgr.LevelBraces- wraps levels with "[" and "]"lgr.Msec- adds milliseconds to timestamplgr.Out(io.Writer)- sets the output writer, defaultos.Stdoutlgr.Err(io.Writer)- sets the error writer, defaultos.Stderr
levels
lgr.Logf recognizes prefixes like "INFO" or "[INFO]" as levels. The full list of supported levels - "DEBUG", "INFO", "WARN", "ERROR", "PANIC" and "FATAL"
DEBUGwill be filtered unlesslgr.Debugoption definedINFOandWARNdon't have any special behavior attachedERRORsends messages to both out and err writersPANICandFATALsend messages to both out and err writers. In addition sends dump of callers and runtime info to err only, and callsos.Exit(1).
global logger
Users should avoid global logger and pass the concrete logger as a dependency. However, in some cases a global logger may be needed, for example migration from stdlib log to lgr. For such cases log "github.com/go-pkgz/lgr" can be imported instead of log package.
Global logger provides lgr.Printf, lgr.Print and lgr.Fatalf functions. User can customize the logger by calling lgr.Setup(options ...). The instance of this logger can be retrieved with lgr.Default()