Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustGetLogger ¶
func MustGetLogger(name string, opts ...LoggerOption) (*zap.Logger, func())
MustGetLogger creates a named zap logger, typically to inject into a service runtime as the root logger.
This function returns a configured zap.Logger and a closing function to sync logs upon exit.
It panics upon failures, such as invalid log level, or incapacity to build the underlying logger.
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is the default logging wrapper that can create logger instances either contextless, or for a given context (e.g. to propagate trace spans).
A factory wraps a logger to propagate log entries as trace spans.
Loggers are zap structured loggers: see go.uber.org/zap.
func GetTestLoggerConfig ¶
GetTestLoggerConfig is intended to be used in test programs, and inject a logger factory or its underlying *zap.Logger into the tested components.
It is configurable from the "DEBUG_TEST" environment variable: if set, logging is enabled. Otherwise, logging is just muted, allowing to keep test verbosity low.
func MustGetTestLoggerConfig ¶
MustGetTestLoggerConfig is a wrapper around GetTestLoggerConfig that panics if an error is encountered.
func NewFactory ¶
NewFactory creates a new logger Factory for an underlying zap logger.
func (Factory) For ¶
For returns a context-aware Logger.
If the context contains an OpenTracing span, all logging calls are also echo-ed to that span.
NOTE: for Datadog trace correlation, extra fields "dd.trace_id" and "dd.span_id" fields are added to the log entry.
type Logger ¶
type Logger interface { Debug(msg string, fields ...zapcore.Field) Info(msg string, fields ...zapcore.Field) Warn(msg string, fields ...zapcore.Field) Error(msg string, fields ...zapcore.Field) Fatal(msg string, fields ...zapcore.Field) With(fields ...zapcore.Field) Logger }
Logger is a simplified abstraction of the zap.Logger
type LoggerOption ¶
type LoggerOption func(*loggerOptions)
LoggerOption sets options to tune the behavior of a logger.
func WithCallerSkip ¶
func WithCallerSkip(skipped int) LoggerOption
WithCallerSkip sets the number of frames in the stack to skip.
By default, this is set to 1, so the logging function itself is skipped.
func WithDisableStackTrace ¶
func WithDisableStackTrace(disabled bool) LoggerOption
WithDisableStackTrace disable stack printing for this logger
func WithLevel ¶
func WithLevel(level string) LoggerOption
WithLevel sets the log level.
The level value must parse to a valid zapcore.Level, i.e. one of error, warn, info, debug values. The default level is "info".
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package exporter provides extra trace span exporters, which may be added to some standard exporter such as jaeger or datadog.
|
Package exporter provides extra trace span exporters, which may be added to some standard exporter such as jaeger or datadog. |
amplitude
Package amplitude exposes an exporter to route span traces to the Amplitude API.
|
Package amplitude exposes an exporter to route span traces to the Amplitude API. |
influxdb
Package influxdb exposes an opencensus stats exporter for influxdb.
|
Package influxdb exposes an opencensus stats exporter for influxdb. |
opentelemetry
Package opentelemetry should export traces produced by opencensus package to an opentelemetry backend.
|
Package opentelemetry should export traces produced by opencensus package to an opentelemetry backend. |