Documentation ¶
Overview ¶
Package zaputil contains common code for passing a zap logger around. It's a convenient space for putting custom logger implementations for plugging into various locations.
Index ¶
- func Extract(ctx context.Context) *zap.Logger
- func HashiCorpStdLogger(logger *zap.Logger) *log.Logger
- func HashicorpStdLogger(logger *zap.Logger) *log.Logger
- func Setup(ctx context.Context, cfg Config) context.Context
- func ToContext(ctx context.Context, logger *zap.Logger) context.Context
- type BadgerLogger
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
Extract pulls the logger from the provided context. If no logger is found, then the defaultLogger is returned.
func HashiCorpStdLogger ¶
HashiCorpStdLogger wraps the provided logger with a golang logger to log messages at the appropriate level using the HashiCorp log format. Useful for replacing serf and membership loggers.
func HashicorpStdLogger ¶
HashicorpStdLogger Deprecated.
Types ¶
type BadgerLogger ¶
type BadgerLogger interface { Errorf(string, ...interface{}) Warningf(string, ...interface{}) Infof(string, ...interface{}) Debugf(string, ...interface{}) }
BadgerLogger is an interface pulled from the badger library. It defines the functionality needed by the badger system to log messages. It supports a variety of levels and works similar to the fmt.Printf method.
func Badger ¶
func Badger(log *zap.Logger) BadgerLogger
Badger wraps the provided logger so badger can log using zap.
type Config ¶
type Config struct { Level string `json:"level" usage:"adjust the verbosity of the logs" default:"info"` Format string `json:"format" usage:"configure the format of the logs" default:"json"` }
Config encapsulates the configurable elements of the logger.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default configuration for zap to use. By default, it logs at an info level and infers the log format based on the stdout device. If it looks like a terminal session, then it uses the console format.