Documentation ¶
Overview ¶
Package sugarkane tries to make it easy to show info to the user and the log with one call.
Example ¶
https://blog.golang.org/examples
package main import ( "os" "github.com/bbkane/sugarkane" "go.uber.org/zap" lumberjack "gopkg.in/natefinch/lumberjack.v2" ) func main() { // intialize a more useful lumberjack.Logger with: // https://github.com/natefinch/lumberjack var lumberjackLogger *lumberjack.Logger = nil sk := sugarkane.NewSugarKane(lumberjackLogger, os.Stderr, os.Stdout, zap.DebugLevel, "v1.0.0") defer sk.Sync() sk.LogOnPanic() sk.Infow( "Now we're logging :)", "key", "value", ) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SugarKane ¶
type SugarKane struct {
// contains filtered or unexported fields
}
SugarKane 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 NewSugarKane ¶
func NewSugarKane(lumberjackLogger *lumberjack.Logger, errorStream *os.File, infoStream *os.File, lvl zapcore.LevelEnabler, appVersion string) *SugarKane
NewSugarKane creates a new SugarKane all ready to go
func (*SugarKane) LogOnPanic ¶
func (s *SugarKane) LogOnPanic()
LogOnPanic tries to log a panic. It should be called at the start of each goroutine. See panic and recover docs
Click to show internal directories.
Click to hide internal directories.