Documentation ¶
Overview ¶
Example ¶
https://blog.golang.org/examples
package main import ( "go.bbkane.com/gocolor" "go.bbkane.com/logos" "go.uber.org/zap" lumberjack "gopkg.in/natefinch/lumberjack.v2" ) func main() { // See https://github.com/natefinch/lumberjack for more options var lumberjackLogger *lumberjack.Logger = &lumberjack.Logger{ Filename: "/tmp/testlog.jsonl", MaxSize: 1, // megabytes MaxAge: 0, MaxBackups: 0, LocalTime: true, Compress: false, } color, err := gocolor.Prepare(true) if err != nil { panic(err) } l := logos.New( logos.NewBBKaneZapLogger(lumberjackLogger, zap.DebugLevel, "v1.0.0"), color, ) defer l.Sync() l.LogOnPanic() l.Infow( "Now we're logging :)", "key", "value", "otherkey", "othervalue", ) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBBKaneZapLogger ¶ added in v0.4.0
func NewBBKaneZapLogger(lumberjackLogger *lumberjack.Logger, lvl zapcore.LevelEnabler, appVersion string) *zap.Logger
NewBBKaneZapLogger builds a zap.SugaredLogger configured with settings I like. As a special case, if lumberjackLogger == nil, then returns zap.newNop
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a very opinionated wrapper around a uber/zap sugared logger It's designed primarily to simultaneously print "pretty-enough" input for a user and useful enough info to a lumberjack logger It should really only be used with simple key/value pairs It's designed to be fairly easily swappable with the sugared logger
func NewNop ¶ added in v0.4.0
func NewNop() *Logger
NewNop returns a no-op Logger. It never writes logs or prints
func (*Logger) LogOnPanic ¶
func (l *Logger) LogOnPanic()
LogOnPanic tries to log a panic. It should be called at the start of each goroutine. See panic and recover docs
type LoggerOpt ¶ added in v0.4.0
type LoggerOpt func(*Logger)
LoggerOpt allows customizations to New
func WithStderr ¶ added in v0.4.0
WithStderr overrides stderr for the logger
func WithStdout ¶ added in v0.4.0
WithStdout overrides stdout for the logger