Documentation ¶
Overview ¶
Package zapr provides a logr.Logger interface around a zap implementation, including metrics and a standard library log.Logger adapter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStdErrorLogger ¶
func NewStdErrorLogger(logger logr.CallDepthLogger) *log.Logger
NewStdErrorLogger returns a *log.Logger which writes to the supplied Logger's Error method.
func NewStdInfoLogger ¶
func NewStdInfoLogger(logger logr.CallDepthLogger) *log.Logger
NewStdInfoLogger returns a *log.Logger which writes to the supplied Logger's Info method.
Types ¶
type Config ¶
type Config struct { Name string Level int TimeKey string LevelKey string NameKey string CallerKey string FunctionKey string MessageKey string ErrorKey string StacktraceKey string LineEnding string Encoder encoding.Encoder TimeEncoder encoding.TimeEncoder LevelEncoder encoding.LevelEncoder DurationEncoder encoding.DurationEncoder CallerEncoder encoding.CallerEncoder EnableStacktrace bool EnableCaller bool Development bool SampleInitial int SampleThereafter int Metrics Metrics }
Config specifies the configuration of a Logger.
func DevelopmentConfig ¶
func DevelopmentConfig() *Config
DevelopmentConfig returns a development-friendly Config.
func (*Config) RegisterCommonFlags ¶
RegisterCommonFlags registers basic fields of the Config as flags in the FlagSet. If fs is nil, flag.CommandLine is used.
type Logger ¶
type Logger interface { // This is the main logging interface. All methods that return a logr.Logger // (e.g. V, WithValues, WithName, WithCallDepth) will return a value implementing // zapr.Logger (e.g. with the additional Underlying and Flush methods). logr.CallDepthLogger // Underlying returns the underlying *zap.Logger with no caller skips. // It may return nil if the logger is disabled. Underlying() *zap.Logger // Flush writes any buffered data to the underlying io.Writer. Flush() error }
Logger represents the ability to log messages, both errors and not.
type Metrics ¶
type Metrics interface { // Init initializes metrics for the named logger when it's created. // Logger names are not required to be unique and it may be called // with a duplicate name at any time. Init(logger string) // ObserveEntryLogged observes logged entry metrics for the named logger, at // the given level, and with the given bytes. ObserveEntryLogged(logger string, level string, bytes int) // ObserveEncoderError observes an error encoding an entry for the named logger. ObserveEncoderError(logger string) }
Metrics represent the ability to observe log metrics.
Directories ¶
Path | Synopsis |
---|---|
Package encoding provides named encoders with flag integration.
|
Package encoding provides named encoders with flag integration. |
Package zaprprom provides a Prometheus metrics implementation for zapr.
|
Package zaprprom provides a Prometheus metrics implementation for zapr. |