Documentation ¶
Overview ¶
Package logger provides a wrapper around logrus to add standard fields to the log entry. It will also add the span context to logrus entry. logrus: https://github.com/sirupsen/logrus
Index ¶
- func Debug(msg string, attribs ...Attribute)
- func DebugWithSpanContext(sCtx context.Context, msg string, attribs ...Attribute)
- func Error(err error, msg string, attribs ...Attribute)
- func ErrorWithSpanContext(sCtx context.Context, err error, msg string, attribs ...Attribute)
- func Fatal(err error, msg string, attribs ...Attribute)
- func FatalWithSpanContext(sCtx context.Context, err error, msg string, attribs ...Attribute)
- func Info(msg string, attribs ...Attribute)
- func InfoWithSpanContext(sCtx context.Context, msg string, attribs ...Attribute)
- func Initialize(out io.Writer, level logrus.Level, hooks ...logrus.Hook)
- func IsInitialized() bool
- func LoggingMiddleware() gin.HandlerFunc
- func Warn(msg string, attribs ...Attribute)
- func WarnWithSpanContext(sCtx context.Context, msg string, attribs ...Attribute)
- type Attribute
- type HttpWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
Debug logs a message at the debug level and any additional fields passed in as attributes.
func DebugWithSpanContext ¶
DebugWithSpanContext logs a message at the debug level with a span context and any additional fields passed in as attributes, as well as the trace_id and span_id.
func Error ¶
Error logs a message at the error level and any additional fields passed in as attributes.
func ErrorWithSpanContext ¶
ErrorWithSpanContext logs a message at the error level with a span context and any additional fields passed in as attributes, as well as the trace_id and span_id.
func Fatal ¶
Fatal logs a message at the fatal level and any additional fields passed in as attributes.
func FatalWithSpanContext ¶
FatalWithSpanContext logs a message at the fatal level with a span context and any additional fields passed in as attributes, as well as the trace_id and span_id.
func Info ¶
Info logs a message at the info level and any additional fields passed in as attributes.
func InfoWithSpanContext ¶
InfoWithSpanContext logs a message at the info level with a span context and any additional fields passed in as attributes, as well as the trace_id and span_id.
func Initialize ¶
Initialize sets up the logger with the given log level and formatter.
func IsInitialized ¶
func IsInitialized() bool
IsInitialized returns true if the logger has been successfully initialized.
func LoggingMiddleware ¶
func LoggingMiddleware() gin.HandlerFunc
LoggingMiddleware logs the incoming request and starts the trace.
Types ¶
type Attribute ¶
type Attribute struct { Key string Value interface{} }
Attribute is a key-value pair that can be added to a logrus message.
func ParseHeaders ¶
ParseHeaders parses the headers and returns a map of attributes.
func ParseUserAgent ¶
ParseUserAgent parses the user agent string and returns a map of attributes.
type HttpWriter ¶
HttpWriter is an interface that defines an io.Writer that writes to an HTTP endpoint.
func NewHttpWriter ¶
func NewHttpWriter(url string) HttpWriter
NewHttpWriter creates a new io.Writer that writes to an HTTP stream.