Documentation ¶
Index ¶
- Constants
- Variables
- func AddCorrelationIDsToLogger(ctx context.Context, correlationID, traceID, spanID, parentSpanID string) *logrus.Entry
- func AddHook(hook logrus.Hook)
- func Configure(ctx context.Context, config *Config) (context.Context, error)
- func ContextWithLogger(ctx context.Context, entry *logrus.Entry) context.Context
- func ContextWithMdc(ctx context.Context) context.Context
- func DefaultLogger() *logrus.Entry
- func LoggerFromContext(ctx context.Context) *logrus.Entry
- func LoggerWithCorrelationID(r *http.Request) *logrus.Entry
- func LoggerWithParentSpanID(r *http.Request, entry *logrus.Entry) *logrus.Entry
- func LoggerWithSpanID(r *http.Request, entry *logrus.Entry) *logrus.Entry
- func LoggerWithTraceID(r *http.Request, entry *logrus.Entry) *logrus.Entry
- func NewGqlLoggingInterceptor() *opsInterceptor
- func RegisterFormatter(name string, formatter logrus.Formatter) error
- func RequestLogger(pathsToLogOnDebug ...string) func(next http.Handler) http.Handler
- type Config
- type ErrorLocationHook
- type MDC
Constants ¶
const ( // FieldRequestID represent the request ID field name in the logger derived from the istio 'x-request-id' header FieldRequestID = "x-request-id" // FieldTraceID represent the trace ID field name in the logger derived from the istio 'x-b3-traceid' header FieldTraceID = "x-trace-id" // FieldSpanID represent the span ID field name in the logger derived from the istio 'x-b3-spanid' header FieldSpanID = "x-span-id" // FieldParentSpanID represent the parent span ID field name in the logger derived from the istio 'x-b3-parentspanid' header FieldParentSpanID = "x-parent-span-id" // FieldFormationID represent the formation field name in the logger FieldFormationID = "formation-id" // FieldFormationAssignmentID represent the formation assignment field name in the logger FieldFormationAssignmentID = "formation-assignment-id" )
Variables ¶
var ( // C missing godoc C = LoggerFromContext // D missing godoc D = DefaultLogger )
Functions ¶
func AddCorrelationIDsToLogger ¶
func AddCorrelationIDsToLogger(ctx context.Context, correlationID, traceID, spanID, parentSpanID string) *logrus.Entry
AddCorrelationIDsToLogger adds all correlation IDs to the logger
func ContextWithLogger ¶
ContextWithLogger returns a new context with the provided logger.
func ContextWithMdc ¶
ContextWithMdc returns a new context with attached MDC
func LoggerFromContext ¶
LoggerFromContext retrieves the current logger from the context.
func LoggerWithCorrelationID ¶
LoggerWithCorrelationID missing godoc
func LoggerWithParentSpanID ¶
LoggerWithParentSpanID adds the parent span ID to the logger
func LoggerWithSpanID ¶
LoggerWithSpanID adds the span ID to the logger
func LoggerWithTraceID ¶
LoggerWithTraceID adds the trace ID to the logger
func NewGqlLoggingInterceptor ¶
func NewGqlLoggingInterceptor() *opsInterceptor
NewGqlLoggingInterceptor creates a new opsInterceptor instance
func RegisterFormatter ¶
RegisterFormatter registers a new logrus Formatter with the given name. Returns an error if there is a formatter with the same name.
Types ¶
type Config ¶
type Config struct { Level string `envconfig:"APP_LOG_LEVEL,default=info"` Format string `envconfig:"APP_LOG_FORMAT,default=text"` Output string `envconfig:"APP_LOG_OUTPUT,default=/dev/stdout"` BootstrapCorrelationID string `envconfig:"APP_LOG_BOOTSTRAP_CORRELATION_ID,default=bootstrap"` }
Config missing godoc
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns default values for Log settings
type ErrorLocationHook ¶
type ErrorLocationHook struct { }
ErrorLocationHook provides an implementation of the sirupsen/logrus/Hook interface. Attaches error location information to log entries if an error is being logged and it has stack-trace information (i.e. if it originates from or is wrapped by github.com/pkg/errors).
func (*ErrorLocationHook) Fire ¶
func (h *ErrorLocationHook) Fire(entry *logrus.Entry) error
Fire missing godoc
func (*ErrorLocationHook) Levels ¶
func (h *ErrorLocationHook) Levels() []logrus.Level
Levels missing godoc
type MDC ¶
type MDC struct {
// contains filtered or unexported fields
}
MDC provides a mechanism to enrich the log messages with information, which might not be available at the time/scope where the logging actually occurs.
func MdcFromContext ¶
MdcFromContext returns the attached *MDC or nil if there is none
func NewMappedDiagnosticContext ¶
func NewMappedDiagnosticContext() *MDC
NewMappedDiagnosticContext creates a new MDC instance
func (*MDC) SetIfNotEmpty ¶
SetIfNotEmpty adds or overwrites a key-value pair in the MDC but only if the value is not empty