wip
This commit is contained in:
parent
3715e291bb
commit
ccaf9fcd75
|
|
@ -53,6 +53,8 @@ package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/valyala/fasttemplate"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -101,11 +103,31 @@ func NewEcho() *echo.Echo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger
|
// Logger
|
||||||
|
|
||||||
if !config.LogEnabled.GetBool() || config.LogHTTP.GetString() != "off" {
|
if !config.LogEnabled.GetBool() || config.LogHTTP.GetString() != "off" {
|
||||||
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
logWriter := log.GetLogWriter(config.LogHTTP.GetString(), "http")
|
||||||
Format: log.WebFmt + "\n",
|
template := fasttemplate.New(log.WebFmt, "${", "}")
|
||||||
Output: log.GetLogWriter(config.LogHTTP.GetString(), "http"),
|
e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
|
||||||
|
LogStatus: true,
|
||||||
|
LogURI: true,
|
||||||
|
LogRemoteIP: true,
|
||||||
|
LogRequestID: true,
|
||||||
|
LogMethod: true,
|
||||||
|
LogLatency: true,
|
||||||
|
LogUserAgent: true,
|
||||||
|
LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
|
||||||
|
logWriter.Write()
|
||||||
|
//`${time_rfc3339}: WEB ` + "\t" + `▶ ${remote_ip} ${id} ${method} ${status} ${uri} ${latency_human} - ${user_agent}`
|
||||||
|
value, _ := c.Get("customValueFromContext").(int)
|
||||||
|
fmt.Printf("REQUEST: uri: %v, status: %v, custom-value: %v\n", v.URI, v.Status, value)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
//e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||||||
|
// Format: log.WebFmt + "\n",
|
||||||
|
// Output: log.GetLogWriter(config.LogHTTP.GetString(), "http"),
|
||||||
|
// }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// panic recover
|
// panic recover
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue