logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 9 Imported by: 4

Documentation

Overview

Package logger implements middleware for request logging.

Index

Constants

This section is empty.

Variables

View Source
var Std = Func(func(format string, args ...interface{}) { log.Printf(format, args...) })

Std logger sends to std default logger directly

Functions

func Prefix

func Prefix(prefix string) func(m *Middleware)

Prefix sets logging prefix for each line

func WithBody

func WithBody(m *Middleware)

WithBody enables body logging

func WithHeaders

func WithHeaders(m *Middleware)

WithHeaders enables headers logging

Types

type Func

type Func func(format string, args ...interface{})

Func type is an adapter to allow the use of ordinary functions as Service.

func (Func) Logf

func (f Func) Logf(format string, args ...interface{})

Logf calls f(id)

type Middleware

type Middleware struct {
	Service
	// contains filtered or unexported fields
}

Middleware for logging requests

func New

func New(svc Service, opts ...func(m *Middleware)) *Middleware

New creates logging middleware with optional parameters turning on logging elements

func (Middleware) Middleware

func (m Middleware) Middleware(next http.RoundTripper) http.RoundTripper

Middleware request logging

type Service

type Service interface {
	Logf(format string, args ...interface{})
}

Service defined logger interface used everywhere in the package

Jump to

Keyboard shortcuts

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