logger

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, attribs ...Attribute)

Debug logs a message at the debug level and any additional fields passed in as attributes.

func DebugWithSpanContext

func DebugWithSpanContext(sCtx context.Context, msg string, attribs ...Attribute)

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

func Error(err error, msg string, attribs ...Attribute)

Error logs a message at the error level and any additional fields passed in as attributes.

func ErrorWithSpanContext

func ErrorWithSpanContext(sCtx context.Context, err error, msg string, attribs ...Attribute)

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

func Fatal(err error, msg string, attribs ...Attribute)

Fatal logs a message at the fatal level and any additional fields passed in as attributes.

func FatalWithSpanContext

func FatalWithSpanContext(sCtx context.Context, err error, msg string, attribs ...Attribute)

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

func Info(msg string, attribs ...Attribute)

Info logs a message at the info level and any additional fields passed in as attributes.

func InfoWithSpanContext

func InfoWithSpanContext(sCtx context.Context, msg string, attribs ...Attribute)

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

func Initialize(out io.Writer, level logrus.Level, hooks ...logrus.Hook)

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.

func Warn

func Warn(msg string, attribs ...Attribute)

Warn logs a message at the warn level and any additional fields passed in as attributes.

func WarnWithSpanContext

func WarnWithSpanContext(sCtx context.Context, msg string, attribs ...Attribute)

WarnWithSpanContext logs a message at the warn level with a span context and any additional fields passed in as attributes, as well as the trace_id and span_id.

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

func ParseHeaders(headers map[string][]string) (hdrMap []Attribute)

ParseHeaders parses the headers and returns a map of attributes.

func ParseUserAgent

func ParseUserAgent(rawUserAgent string) (uaMap []Attribute)

ParseUserAgent parses the user agent string and returns a map of attributes.

type HttpWriter

type HttpWriter interface {
	io.Writer
	IsReady() bool
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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