Logger: Add feature toggle for errors in HTTP request logs (#64425)

This commit is contained in:
Emil Tullstedt
2023-03-31 15:38:09 +02:00
committed by GitHub
parent 977a7e9a55
commit be9361cb9e
19 changed files with 488 additions and 199 deletions
+5
View File
@@ -16,6 +16,7 @@ package web
import (
"encoding/json"
"errors"
"fmt"
"html/template"
"net"
@@ -23,6 +24,7 @@ import (
"net/url"
"strconv"
"strings"
"syscall"
"github.com/grafana/grafana/pkg/util/errutil"
"github.com/grafana/grafana/pkg/util/errutil/errhttp"
@@ -104,6 +106,9 @@ func (ctx *Context) HTML(status int, name string, data interface{}) {
ctx.Resp.Header().Set(headerContentType, contentTypeHTML)
ctx.Resp.WriteHeader(status)
if err := ctx.template.ExecuteTemplate(ctx.Resp, name, data); err != nil {
if errors.Is(err, syscall.EPIPE) { // Client has stopped listening.
return
}
panic(fmt.Sprintf("Context.HTML - Error rendering template: %s. You may need to build frontend assets \n %s", name, err.Error()))
}
}