|
|
|
@ -32,8 +32,6 @@ type LogFormatterParams struct { |
|
|
|
StatusCode int |
|
|
|
StatusCode int |
|
|
|
// Latency is how much time the server cost to process a certain request.
|
|
|
|
// Latency is how much time the server cost to process a certain request.
|
|
|
|
Latency time.Duration |
|
|
|
Latency time.Duration |
|
|
|
// ClientIP equals Context's ClientIP method.
|
|
|
|
|
|
|
|
ClientIP string |
|
|
|
|
|
|
|
// Method is the HTTP method given to the request.
|
|
|
|
// Method is the HTTP method given to the request.
|
|
|
|
Method string |
|
|
|
Method string |
|
|
|
// Path is a path the client requests.
|
|
|
|
// Path is a path the client requests.
|
|
|
|
@ -123,7 +121,6 @@ func LoggerWithConfig(c LogConfig) MiddlewareFunc { |
|
|
|
Request: r, |
|
|
|
Request: r, |
|
|
|
TimeStamp: stop, |
|
|
|
TimeStamp: stop, |
|
|
|
Latency: stop.Sub(start), |
|
|
|
Latency: stop.Sub(start), |
|
|
|
ClientIP: "", |
|
|
|
|
|
|
|
Method: r.Method, |
|
|
|
Method: r.Method, |
|
|
|
StatusCode: sw.status, |
|
|
|
StatusCode: sw.status, |
|
|
|
Path: path, |
|
|
|
Path: path, |
|
|
|
@ -143,11 +140,10 @@ func formatter(p LogFormatterParams) string { |
|
|
|
p.Latency = p.Latency - p.Latency%time.Second |
|
|
|
p.Latency = p.Latency - p.Latency%time.Second |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return fmt.Sprintf("[MUX] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n", |
|
|
|
return fmt.Sprintf("[MUX] %v |%s %3d %s| %13v |%s %-7s %s %s\n", |
|
|
|
p.TimeStamp.Format("2006/01/02 - 15:04:05"), |
|
|
|
p.TimeStamp.Format("2006/01/02 - 15:04:05"), |
|
|
|
statusColor, p.StatusCode, resetColor, |
|
|
|
statusColor, p.StatusCode, resetColor, |
|
|
|
p.Latency, |
|
|
|
p.Latency, |
|
|
|
p.ClientIP, |
|
|
|
|
|
|
|
methodColor, p.Method, resetColor, |
|
|
|
methodColor, p.Method, resetColor, |
|
|
|
p.Path, |
|
|
|
p.Path, |
|
|
|
) |
|
|
|
) |
|
|
|
|