logger

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(logger Logger, logHeaders bool) func(http.Handler) http.Handler

LoggingMiddleware creates a middleware that logs requests

Types

type JSONLLogger

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

JSONLLogger logs in JSON Lines format

func NewJSONLLogger

func NewJSONLLogger(w io.Writer) *JSONLLogger

NewJSONLLogger creates a new JSONL logger

func (*JSONLLogger) LogError

func (l *JSONLLogger) LogError(msg string, err error)

LogError logs an error with JSONL format

func (*JSONLLogger) LogHeaders

func (l *JSONLLogger) LogHeaders(r *http.Request)

LogHeaders logs request headers with JSONL format WARNING: This may log sensitive data (e.g., Authorization headers). Only enable header logging in development or when debugging specific issues.

func (*JSONLLogger) LogInfo

func (l *JSONLLogger) LogInfo(msg string)

LogInfo logs an informational message with JSONL format

func (*JSONLLogger) LogRequest

func (l *JSONLLogger) LogRequest(r *http.Request, status int, duration time.Duration)

LogRequest logs an HTTP request with JSONL format

type LogEntry

type LogEntry struct {
	Timestamp string                 `json:"timestamp"`
	Level     string                 `json:"level"`
	Message   string                 `json:"message,omitempty"`
	Method    string                 `json:"method,omitempty"`
	Path      string                 `json:"path,omitempty"`
	Status    int                    `json:"status,omitempty"`
	Duration  string                 `json:"duration,omitempty"`
	Headers   map[string]interface{} `json:"headers,omitempty"`
	Error     string                 `json:"error,omitempty"`
}

LogEntry represents a structured log entry

type Logger

type Logger interface {
	LogRequest(r *http.Request, status int, duration time.Duration)
	LogError(msg string, err error)
	LogInfo(msg string)
	LogHeaders(r *http.Request)
}

Logger interface for flexible logging

type TextLogger

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

TextLogger logs in traditional text format

func NewTextLogger

func NewTextLogger() *TextLogger

NewTextLogger creates a new text logger

func (*TextLogger) LogError

func (l *TextLogger) LogError(msg string, err error)

LogError logs an error with text format

func (*TextLogger) LogHeaders

func (l *TextLogger) LogHeaders(r *http.Request)

LogHeaders logs request headers with text format WARNING: This may log sensitive data (e.g., Authorization headers). Only enable header logging in development or when debugging specific issues.

func (*TextLogger) LogInfo

func (l *TextLogger) LogInfo(msg string)

LogInfo logs an informational message with text format

func (*TextLogger) LogRequest

func (l *TextLogger) LogRequest(r *http.Request, status int, duration time.Duration)

LogRequest logs an HTTP request with text format

Jump to

Keyboard shortcuts

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