logger

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 4 Imported by: 14

Documentation

Index

Constants

View Source
const RequestIDFieldName = "requestID"

Variables

This section is empty.

Functions

func NewZapLogger

func NewZapLogger(level zapcore.Level, logFormat string) (*zap.Logger, error)

NewZapLogger creates a *zap.Logger using the base config

Types

type Logger

type Logger struct {
	Logger *zap.Logger
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(logger *zap.Logger, reqIDLogging bool) *Logger

NewLogger returns the logging wrapper for a given *zap.logger. Noop logger bypasses the setting of fields, improving performance. If *zap.Logger is nil a noop logger is set and the reqIDLogging argument is overwritten to false

func (*Logger) ClearFields

func (l *Logger) ClearFields(reqID string)

ClearFields clears all stored fields for a given requestID, important for maintaining performance

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zap.Field)

func (*Logger) DebugWithID

func (l *Logger) DebugWithID(reqID string, msg string, fields ...zap.Field)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zap.Field)

func (*Logger) ErrorWithID

func (l *Logger) ErrorWithID(reqID string, msg string, fields ...zap.Field)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...zap.Field)

func (*Logger) FatalWithID

func (l *Logger) FatalWithID(reqID string, msg string, fields ...zap.Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zap.Field)

func (*Logger) InfoWithID

func (l *Logger) InfoWithID(reqID string, msg string, fields ...zap.Field)

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zap.Field)

func (*Logger) WarnWithID

func (l *Logger) WarnWithID(reqID string, msg string, fields ...zap.Field)

func (*Logger) WithFields

func (l *Logger) WithFields(fields ...zap.Field) *Logger

WithFields creates a new logging wrapper with a predefined base set of fields. These fields will be added to each request, but the logger will still read/write from the highest level logging wrappers field pool

func (*Logger) WriteFields

func (l *Logger) WriteFields(reqID string, fields ...zap.Field)

WriteFields adds field key and value pairs to the highest level Logger, they will be applied to all subsequent log calls using the matching requestID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL