mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-30 08:51:30 +00:00
log request failures
This commit is contained in:
parent
e7481b31c1
commit
f8d12054c5
1 changed files with 14 additions and 8 deletions
20
http/http.go
20
http/http.go
|
@ -30,21 +30,27 @@ type Server struct {
|
||||||
func makeHandler(handler ResponseHandler) httprouter.Handle {
|
func makeHandler(handler ResponseHandler) httprouter.Handle {
|
||||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
httpCode, err := handler(w, r, p)
|
httpCode, err := handler(w, r, p)
|
||||||
stats.RecordEvent(stats.HandledRequest)
|
stats.RecordEvent(stats.HandledRequest)
|
||||||
|
duration := time.Since(start)
|
||||||
|
stats.RecordTiming(stats.ResponseTime, duration)
|
||||||
|
|
||||||
if err != nil && err != models.ErrBadRequest {
|
if err != nil && err != models.ErrBadRequest {
|
||||||
stats.RecordEvent(stats.ErroredRequest)
|
stats.RecordEvent(stats.ErroredRequest)
|
||||||
http.Error(w, err.Error(), httpCode)
|
http.Error(w, err.Error(), httpCode)
|
||||||
}
|
|
||||||
|
|
||||||
duration := time.Since(start)
|
|
||||||
stats.RecordTiming(stats.ResponseTime, duration)
|
|
||||||
|
|
||||||
if glog.V(2) {
|
if glog.V(2) {
|
||||||
glog.Infof(
|
glog.Infof(
|
||||||
"Completed %v %s %s in %v",
|
"Failed (%v:%s) %s with %s in %s",
|
||||||
|
httpCode,
|
||||||
|
http.StatusText(httpCode),
|
||||||
|
r.URL.Path,
|
||||||
|
err.Error(),
|
||||||
|
duration,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if glog.V(2) {
|
||||||
|
glog.Infof(
|
||||||
|
"Completed (%v:%s) %s in %v",
|
||||||
httpCode,
|
httpCode,
|
||||||
http.StatusText(httpCode),
|
http.StatusText(httpCode),
|
||||||
r.URL.Path,
|
r.URL.Path,
|
||||||
|
|
Loading…
Add table
Reference in a new issue