accesslog

package
v0.0.0-...-1225d9a Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoggerDefaultDateFormat = time.RFC3339

LoggerDefaultDateFormat is the format used for date by the default Logger instance.

View Source
var LoggerDefaultFormat = "{{.Status}} | {{.Duration}} | {{.Hostname}} | {{.Method}} {{.Path}}"

LoggerDefaultFormat is the format logged used by the default Logger instance.

Functions

This section is empty.

Types

type DebugFunc

type DebugFunc func(msg string)

type Logger

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

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

func New

func New() *Logger

New returns a new Logger instance

func (*Logger) Handler

func (l *Logger) Handler(next http.Handler) http.Handler

Handler 实现中间件

func (*Logger) SetDateFormat

func (l *Logger) SetDateFormat(format string)

SetDateFormat 设置日志的时间格式

func (*Logger) SetDebugFunc

func (l *Logger) SetDebugFunc(fn DebugFunc)

SetLogger 设置logger

func (*Logger) SetFormat

func (l *Logger) SetFormat(format string)

SetFormat 设置日志输出格式的模板

type LoggerEntry

type LoggerEntry struct {
	StartTime string
	Status    int
	Duration  time.Duration
	Hostname  string
	Method    string
	Path      string
	Request   *http.Request
}

LoggerEntry is the structure passed to the template.

Jump to

Keyboard shortcuts

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