logging

package
v0.0.0-...-06858c0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SentryContextKey          = "Poseidon Details"
	SentryFingerprintFieldKey = "sentry-fingerprint"
)
View Source
const GracefulSentryShutdown = 5 * time.Second
View Source
const TimestampFormat = "2006-01-02T15:04:05.000000Z"

Variables

View Source
var ErrHubInvalid = errors.New("the hub is invalid")
View Source
var (
	ErrResponseWriterHijack = errors.New("response writer cannot be hijacked")
)

Functions

func CloneSentryHub

func CloneSentryHub(ctx context.Context) context.Context

func GetLogger

func GetLogger(pkg string) *logrus.Entry

func HTTPLoggingMiddleware

func HTTPLoggingMiddleware(next http.Handler) http.Handler

HTTPLoggingMiddleware returns a http.Handler that logs different information about every request.

func InitializeLogging

func InitializeLogging(logLevel string, formatter dto.Formatter)

func RemoveNewlineSymbol

func RemoveNewlineSymbol(data string) string

RemoveNewlineSymbol GOOD: remove newlines from user controlled input before logging.

func StartSpan

func StartSpan(ctx context.Context, op, description string, callback func(context.Context, *sentry.Span))

Types

type ContextHook

type ContextHook struct{}

ContextHook logs the values referenced by the of dto.LoggedContextKeys. By default, Logrus does not log the values stored in the passed context.

func (*ContextHook) Fire

func (hook *ContextHook) Fire(entry *logrus.Entry) error

Fire is triggered on new log entries.

func (*ContextHook) Levels

func (hook *ContextHook) Levels() []logrus.Level

Levels returns all levels this hook should be registered to.

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	StatusCode int
}

ResponseWriter wraps the default http.ResponseWriter and catches the status code that is written.

func NewLoggingResponseWriter

func NewLoggingResponseWriter(w http.ResponseWriter) *ResponseWriter

func (*ResponseWriter) Hijack

func (writer *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*ResponseWriter) WriteHeader

func (writer *ResponseWriter) WriteHeader(code int)

type SentryHook

type SentryHook struct{}

SentryHook is a simple adapter that converts logrus entries into Sentry events. Consider replacing this with a more feature rich, additional dependency: https://github.com/evalphobia/logrus_sentry

func (*SentryHook) Fire

func (hook *SentryHook) Fire(entry *logrus.Entry) (err error)

Fire is triggered on new log entries.

func (*SentryHook) Levels

func (hook *SentryHook) Levels() []logrus.Level

Levels returns all levels this hook should be registered to.

Jump to

Keyboard shortcuts

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