Documentation ¶
Overview ¶
Package zbark provides a wrapper to make zap.Loggers compatible with the bark.Logger interface and a wrapper to make bark.Loggers compatible with zap.Logger interface.
This package is only of interest to users of github.com/uber-common/bark.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Barkify ¶
Barkify wraps zap's JSON logger to make it compatible with the bark.Logger interface.
Example ¶
package main import ( "github.com/uber-go/zap" "github.com/uber-go/zap/zbark" ) func main() { zapLogger := zap.New(zap.NewJSONEncoder( zap.NoTime(), // discard timestamps in tests )) // Wrap our structured logger to mimic bark.Logger. logger := zbark.Barkify(zapLogger) // The wrapped logger has bark's usual fluent API. logger.WithField("errors", 0).Infof("%v accepts arbitrary types.", "Bark") }
Output: {"level":"info","msg":"Bark accepts arbitrary types.","errors":0}
func Debarkify ¶
Debarkify wraps bark.Logger to make it compatible with zap's JSON logger
Example ¶
package main import ( "os" "github.com/uber-go/zap" "github.com/uber-go/zap/zbark" "github.com/Sirupsen/logrus" "github.com/uber-common/bark" ) func main() { logrusLogger := logrus.New() logrusLogger.Out = os.Stdout logrusLogger.Formatter = &logrus.JSONFormatter{ TimestampFormat: "lies", } barkLogger := bark.NewLoggerFromLogrus(logrusLogger).WithField("errors", 0) logger := zbark.Debarkify(barkLogger, zap.DebugLevel) // The wrapped logger has zap's actually fluent API. logger.Info("Zap accepts", zap.String("typed", "fields")) }
Output: {"errors":0,"level":"info","msg":"Zap accepts","time":"lies","typed":"fields"}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.