logging

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Template:  "{{.Request.Method}} {{.Request.URL.Path}} {{.Duration.String}}",
	Logger:    log.Default(),
	CallDepth: 2,
}

DefaultConfig contains the default value for the logging middleware configuration

Functions

func New

func New(configure ...func(*Config)) lungo.Middleware

New creates a new logging middleware instance

Types

type ColorCode

type ColorCode int

ColorCode defines identifiers to be used as ANSI color escape sequences

const (
	// Error is the ANSI color code for red
	Error ColorCode = 31
	// Success is the ANSI color code for green
	Success ColorCode = 32
	// Warning is the ANSI color code for orange
	Warning ColorCode = 33
	// Info is the ANSI color code for blue
	Info ColorCode = 34
	// Debug is the ANSI color code for magenta
	Debug ColorCode = 35
	// Notice is the ANSI color code for cyan
	Notice ColorCode = 36
	// Reset is the ANSI color code to reset the color
	Reset ColorCode = 0
)

func (ColorCode) Sprintf

func (c ColorCode) Sprintf(a interface{}) string

Sprintf colorizes the provided string by wrapping it inside an ANSI color escape sequence

type Config

type Config struct {
	// Template defines the logging format as a text/template string.
	//
	// see: https://golang.org/pkg/text/template/
	//
	// Available Tags:
	// - "Request": *http.Request
	// - "Duration": *time.Duration
	//
	// Optional. Default:
	Template string

	// Logger defines the log.Logger instance to use for logging.
	// By default the standard logger is used, which makes it
	// equivalent to calling log.Printf().
	//
	// Optional. Default: log.Default()
	Logger *log.Logger

	// CallDepth defines the call stack depth to use for logging.
	//
	// Optional. Default: 2
	CallDepth int
}

Config defines the configuration options for the logging middleware

Jump to

Keyboard shortcuts

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