Help us shape the future of Go! Take the 2026 Go Developer Survey

go_logger_middleware

package module
v0.0.0-...-1827f27 Latest Latest
Warning

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

Go to latest
Published: May 10, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogDefaultDateFormat = time.RFC3339

LogDefaultDateFormat is the format used for date by the default Log instance.

View Source
var LogDefaultFormat = "{{.StartTime}} | {{.Status}} | \t {{.Duration}} | {{.Hostname}} | {{.Method}} {{.Path}} \n"

LogDefaultFormat is the format logged used by the default Log instance.

Functions

This section is empty.

Types

type ALogger

type ALogger interface {
	Println(v ...interface{})
	Printf(format string, v ...interface{})
}

ALogger interface

type LogEntry

type LogEntry struct {
	StartTime string
	Status    int
	Duration  time.Duration
	Hostname  string
	Method    string
	Path      string
}

LogEntry is the structure passed to the template.

type Logger

type Logger struct {
	// LoggerInterface implements more log.Logger interface to be compatible with other implementations
	ALogger
	// contains filtered or unexported fields
}

Log is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewLogger

func NewLogger() *Logger

NewLogger returns a new Logger instance

func NewLoggerWithStream

func NewLoggerWithStream(w io.Writer) *Logger

NewLogger with io.writer returns a new Logger instance

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func (*Logger) SetDateFormat

func (l *Logger) SetDateFormat(format string)

func (*Logger) SetFormat

func (l *Logger) SetFormat(format string)

Jump to

Keyboard shortcuts

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