Documentation ¶
Overview ¶
Package log configures a new logger for an application.
Index ¶
- Constants
- func Middleware(notlogged ...string) gin.HandlerFunc
- func MiddlewareCorrelationId(opts ...MiddlewareOption) gin.HandlerFunc
- func NewErrorStandardLogger(logger logur.Logger) *log.Logger
- func NewLogger(config Config) logur.Logger
- func SetStandardLogger(logger logur.Logger)
- func ToMap(keyvals []interface{}) map[string]interface{}
- func WithFields(logger logur.Logger, fields map[string]interface{}) logur.Logger
- func WithFieldsForHandlers(ctx *gin.Context, logger logur.Logger, fields map[string]interface{}) logur.Logger
- type Config
- type Header
- type MiddlewareOption
Constants ¶
const ContextKey = "correlationid"
ContextKey is the key the retrieved (or generated) correlation ID is stored under in the gin Context.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(notlogged ...string) gin.HandlerFunc
Middleware returns a gin compatible handler.
func MiddlewareCorrelationId ¶
func MiddlewareCorrelationId(opts ...MiddlewareOption) gin.HandlerFunc
MiddlewareCorrelationId returns a gin compatible handler.
func NewErrorStandardLogger ¶
NewErrorStandardLogger returns a new standard logger logging on error level.
func SetStandardLogger ¶
SetStandardLogger sets the global logger's output to a custom logger instance.
func ToMap ¶
func ToMap(keyvals []interface{}) map[string]interface{}
ToMap creates a map of key-value pairs.
The implementation bellow is from go-kit's JSON logger.
func WithFields ¶
WithFields returns a new contextual logger instance with context added to it.
Types ¶
type Config ¶
type Config struct { // Format specifies the output log format. // Accepted values are: json, logfmt Format string // Level is the minimum log level that should appear on the output. Level string // NoColor makes sure that no log output gets colorized. NoColor bool }
Config holds details necessary for logging.
type Header ¶
type Header string
Header configures the header from where the correlation ID will be retrieved.
type MiddlewareOption ¶
type MiddlewareOption interface {
// contains filtered or unexported methods
}
MiddlewareOption configures the correlation ID middleware.