mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-18 17:26:31 +03:00
lib/logger: add WARN level for logging expected errors such as invalid user queries
This commit is contained in:
@@ -146,7 +146,7 @@ func gzipHandler(rh RequestHandler) http.HandlerFunc {
|
||||
handlerWrapper(w, r, rh)
|
||||
if zrw, ok := w.(*gzipResponseWriter); ok {
|
||||
if err := zrw.Close(); err != nil && !isTrivialNetworkError(err) {
|
||||
logger.Errorf("gzipResponseWriter.Close: %s", err)
|
||||
logger.Warnf("gzipResponseWriter.Close: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,10 +329,10 @@ func (zrw *gzipResponseWriter) WriteHeader(statusCode int) {
|
||||
// Implements http.Flusher
|
||||
func (zrw *gzipResponseWriter) Flush() {
|
||||
if err := zrw.bw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
||||
logger.Errorf("gzipResponseWriter.Flush (buffer): %s", err)
|
||||
logger.Warnf("gzipResponseWriter.Flush (buffer): %s", err)
|
||||
}
|
||||
if err := zrw.zw.Flush(); err != nil && !isTrivialNetworkError(err) {
|
||||
logger.Errorf("gzipResponseWriter.Flush (gzip): %s", err)
|
||||
logger.Warnf("gzipResponseWriter.Flush (gzip): %s", err)
|
||||
}
|
||||
if fw, ok := zrw.ResponseWriter.(http.Flusher); ok {
|
||||
fw.Flush()
|
||||
@@ -419,7 +419,7 @@ var (
|
||||
// Errorf writes formatted error message to w and to logger.
|
||||
func Errorf(w http.ResponseWriter, format string, args ...interface{}) {
|
||||
errStr := fmt.Sprintf(format, args...)
|
||||
logger.ErrorfSkipframes(1, "%s", errStr)
|
||||
logger.WarnfSkipframes(1, "%s", errStr)
|
||||
|
||||
// Extract statusCode from args
|
||||
statusCode := http.StatusBadRequest
|
||||
|
||||
Reference in New Issue
Block a user