|
|
@ -196,12 +196,13 @@ func logDetails(r *http.Request, response *detailLoggedResponseWriter, timer *ut
|
|
|
|
logs *internal.LogCollector) {
|
|
|
|
logs *internal.LogCollector) {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
var buf bytes.Buffer
|
|
|
|
duration := timer.Duration()
|
|
|
|
duration := timer.Duration()
|
|
|
|
|
|
|
|
code := response.writer.code
|
|
|
|
logger := logx.WithContext(r.Context())
|
|
|
|
logger := logx.WithContext(r.Context())
|
|
|
|
buf.WriteString(fmt.Sprintf("[HTTP] %s - %d - %s - %s\n=> %s\n",
|
|
|
|
buf.WriteString(fmt.Sprintf("[HTTP] %s - %d - %s - %s\n=> %s\n",
|
|
|
|
r.Method, response.writer.code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r)))
|
|
|
|
r.Method, code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r)))
|
|
|
|
if duration > defaultSlowThreshold {
|
|
|
|
if duration > defaultSlowThreshold {
|
|
|
|
logger.Slowf("[HTTP] %s - %d - %s - slowcall(%s)\n=> %s\n",
|
|
|
|
logger.Slowf("[HTTP] %s - %d - %s - slowcall(%s)\n=> %s\n",
|
|
|
|
r.Method, response.writer.code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r))
|
|
|
|
r.Method, code, r.RemoteAddr, timex.ReprOfDuration(duration), dumpRequest(r))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
body := logs.Flush()
|
|
|
|
body := logs.Flush()
|
|
|
@ -214,7 +215,11 @@ func logDetails(r *http.Request, response *detailLoggedResponseWriter, timer *ut
|
|
|
|
buf.WriteString(fmt.Sprintf("<= %s", respBuf))
|
|
|
|
buf.WriteString(fmt.Sprintf("<= %s", respBuf))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
logger.Info(buf.String())
|
|
|
|
if isOkResponse(code) {
|
|
|
|
|
|
|
|
logger.Info(buf.String())
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
logger.Error(buf.String())
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func isOkResponse(code int) bool {
|
|
|
|
func isOkResponse(code int) bool {
|
|
|
|