Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

main

v2.0.0+incompatible
github.com/djui/chi/_examples/logging

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

11 matches

Top ↑

Custom Structured Logger ======================== This example demonstrates how to use middleware.RequestLogger, middleware.LogFormatter and middleware.LogEntry to build a structured logger using the amazing Sirupsen/logrus package as the logging backend.

Functions

GetLogEntry

func GetLogEntry(r *http.Request) logrus.FieldLogger

LogEntrySetField

func LogEntrySetField(r *http.Request, key string, value interface{})

LogEntrySetFields

func LogEntrySetFields(r *http.Request, fields map[string]interface{})

NewStructuredLogger

func NewStructuredLogger(logger *logrus.Logger) func(next http.Handler) http.Handler

Types

StructuredLogger

type StructuredLogger struct {
	// contains filtered or unexported fields
}

StructuredLogger.NewLogEntry

func (l *StructuredLogger) NewLogEntry(r *http.Request) middleware.LogEntry

StructuredLoggerEntry

type StructuredLoggerEntry struct {
	// contains filtered or unexported fields
}

StructuredLoggerEntry.Panic

func (l *StructuredLoggerEntry) Panic(v interface{}, stack []byte)

StructuredLoggerEntry.Write

func (l *StructuredLoggerEntry) Write(status, bytes int, elapsed time.Duration)

Dependency graph