requestlog

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package requestlog provides HTTP access logging middleware for both server and client requests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(opts ...Option) client.Middleware

Client creates a client-side access logging middleware Parameters:

  • opts: Variable number of Option functions for configuration

Returns:

  • client.Middleware: Client middleware function

Behavior:

  1. Records the start time of the request
  2. Invokes the next handler
  3. Logs request details including latency and response status

Types

type LoggerFactory

type LoggerFactory func(ctx context.Context) (*slog.Logger, error)

LoggerFactory is a function type that creates a logger instance from a context Parameters:

  • ctx: Context that may contain information for creating the logger

Returns:

  • *slog.Logger: Logger instance
  • error: Error if logger creation fails

type Option

type Option func(o *options)

Option is a function type for configuring access log middleware options

func WithLevel

func WithLevel(level slog.Level) Option

WithLevel sets the log level for access log entries Parameters:

  • level: Log level for access logs

Returns:

  • Option: Function to set the log level option

func WithLoggerFactory

func WithLoggerFactory(loggerFactory LoggerFactory) Option

WithLoggerFactory sets the logger factory function Parameters:

  • loggerFactory: Function to create loggers from context

Returns:

  • Option: Function to set the logger factory option

Jump to

Keyboard shortcuts

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