Documentation ¶
Overview ¶
Package logx provides tools to handle log
WithName provides a new logr.Logger:
ctx := context.WithValue(c.Request.Context(), "correlation_id", correlationID) ctx = context.WithValue(ctx, "ipaddress", ip) ctx = context.WithValue(ctx, "kind", "http") log := logx.WithName(ctx, "Test")
GetLogValues returns a keysAndValues model compatible with logrLogger.
var log logr.Logger ctx := context.WithValue(c.Request.Context(), "correlation_id", correlationID) ctx = context.WithValue(ctx, "ipaddress", ip) ctx = context.WithValue(ctx, "kind", "http") kv := logx.GetLogValues(ctx) log = zapr.NewLogger(zapLog) log.Info("test", kv...)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var FieldString = map[string]Field{ "correlation_id": CorrelationID, "kind": Kind, "method": Method, "ipaddress": IPAddress, "uri": URI, }
FieldString match string and Field
Functions ¶
func GetCorrelationID ¶
GetCorrelationID get the correlation id from the context or return an empty string
func GetLogValues ¶
GetLogValues get values from context and return a key/value interface