accesslog

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 7 Imported by: 3

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 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 NewWithLogger

func NewWithLogger(log logger.StandardLogger) *Logger

NewWithLogger with logger

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) SetFormat

func (l *Logger) SetFormat(format string)

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

func (*Logger) SetLogger

func (l *Logger) SetLogger(log logger.StandardLogger)

SetLogger 设置logger

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