Documentation ¶
Index ¶
- Constants
- Variables
- func CloneSentryHub(ctx context.Context) context.Context
- func GetLogger(pkg string) *logrus.Entry
- func HTTPLoggingMiddleware(next http.Handler) http.Handler
- func InitializeLogging(logLevel string, formatter dto.Formatter)
- func RemoveNewlineSymbol(data string) string
- func StartSpan(ctx context.Context, op, description string, ...)
- type ContextHook
- type ResponseWriter
- type SentryHook
Constants ¶
const ( SentryContextKey = "Poseidon Details" SentryFingerprintFieldKey = "sentry-fingerprint" )
const GracefulSentryShutdown = 5 * time.Second
const TimestampFormat = "2006-01-02T15:04:05.000000Z"
Variables ¶
var ErrHubInvalid = errors.New("the hub is invalid")
var (
ErrResponseWriterHijack = errors.New("response writer cannot be hijacked")
)
Functions ¶
func HTTPLoggingMiddleware ¶
HTTPLoggingMiddleware returns a http.Handler that logs different information about every request.
func InitializeLogging ¶
func RemoveNewlineSymbol ¶
RemoveNewlineSymbol GOOD: remove newlines from user controlled input before logging.
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.