Documentation ¶
Index ¶
- Constants
- type LogMetrics
- type Logger
- func (l *Logger) Debug(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Error(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Info(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Warn(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) With(fields ...zap.Field) *Logger
- func (l *Logger) WithOptions(options ...zap.Option)
- type Prm
Constants ¶
const ( DestinationUndefined = "" DestinationStdout = "stdout" DestinationJournald = "journald" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogMetrics ¶ added in v0.38.0
type LogMetrics interface { Inc(level zapcore.Level, dropped bool) GetSamplingHook() func(e zapcore.Entry, sd zapcore.SamplingDecision) }
func NewLogMetrics ¶ added in v0.38.0
func NewLogMetrics(namespace string) LogMetrics
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a component for writing messages to log.
func NewLogger ¶
NewLogger constructs a new zap logger instance. Constructing with nil parameters is safe: default values will be used then. Passing non-nil parameters after a successful creation (non-error) allows runtime reconfiguration.
Logger is built from production logging configuration with:
- parameterized level;
- console encoding;
- ISO8601 time encoding.
Logger records a stack trace for all messages at or above fatal level.
func NewLoggerWrapper ¶ added in v0.44.0
func (*Logger) WithOptions ¶ added in v0.44.0
type Prm ¶
type Prm struct { // SamplingHook hook for the zap.Logger SamplingHook func(e zapcore.Entry, sd zapcore.SamplingDecision) // PrependTimestamp specifies whether to prepend a timestamp in the log PrependTimestamp bool // contains filtered or unexported fields }
Prm groups Logger's parameters. Successful passing non-nil parameters to the NewLogger (if returned error is nil) connects the parameters with the returned Logger. Parameters that have been connected to the Logger support its configuration changing.
Passing Prm after a successful connection via the NewLogger, connects the Prm to a new instance of the Logger.
See also Reload, SetLevelString.
func (Prm) Reload ¶
Reload reloads configuration of a connected instance of the Logger. Returns ErrLoggerNotConnected if no connection has been performed. Returns any reconfiguration error from the Logger directly.
func (*Prm) SetDestination ¶ added in v0.38.0
func (*Prm) SetLevelString ¶
SetLevelString sets the minimum logging level. Default is "info".
Returns an error if s is not a string representation of a supporting logging level.
Supports runtime rereading.