Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultLoggerConfig is the default Logger middleware config. DefaultLoggerConfig = LoggerConfig{ Skipper: middleware.DefaultSkipper, Format: "time:${time_rfc3339}\t" + "host:${remote_ip}\t" + "forwardedfor:${header:x-forwarded-for}\t" + "status:${status}\t" + "method:${method}\t" + "uri:${uri}\t" + "size:${bytes_out}\t" + "referer:${referer}\t" + "ua:${user_agent}\t" + "reqtime:${latency_sec}\t" + "vhost:${host}\t" + "x-request-id:${id}" + "\n", CustomTimeFormat: "2006-01-02 15:04:05.00000", // contains filtered or unexported fields } )
Functions ¶
func Logger ¶
func Logger() echo.MiddlewareFunc
Logger returns a middleware that logs HTTP requests.
func LoggerWithConfig ¶
func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc
LoggerWithConfig returns a Logger middleware with config. See: `Logger()`.
Types ¶
type LoggerConfig ¶
type LoggerConfig struct {
// Skipper defines a function to skip middleware.
Skipper middleware.Skipper
// Tags to construct the logger format.
//
// - time_unix
// - time_unix_milli
// - time_unix_micro
// - time_unix_nano
// - time_rfc3339
// - time_rfc3339_nano
// - time_custom
// - id (Request ID)
// - remote_ip
// - uri
// - host
// - method
// - path
// - protocol
// - referer
// - user_agent
// - status
// - error
// - latency (In nanoseconds)
// - latency_human (Human readable)
// - bytes_in (Bytes received)
// - bytes_out (Bytes sent)
// - header:<NAME>
// - query:<NAME>
// - form:<NAME>
//
// Example "${remote_ip} ${status}"
//
// Optional. Default value DefaultLoggerConfig.Format.
Format string `yaml:"format"`
// Optional. Default value DefaultLoggerConfig.CustomTimeFormat.
CustomTimeFormat string `yaml:"custom_time_format"`
// Output is a writer where logs in JSON format are written.
// Optional. Default value os.Stdout.
Output io.Writer
// contains filtered or unexported fields
}
LoggerConfig defines the config for Logger middleware.
Click to show internal directories.
Click to hide internal directories.