* querylog, stats: don't print unnecessary log messages

This commit is contained in:
Simon Zolin 2019-10-07 12:03:56 +03:00
parent 8b7d23e7d0
commit c9b4a0742f
2 changed files with 6 additions and 4 deletions

View File

@ -62,12 +62,12 @@ func (l *queryLog) Clear() {
l.logBufferLock.Unlock() l.logBufferLock.Unlock()
err := os.Remove(l.logFile + ".1") err := os.Remove(l.logFile + ".1")
if err != nil { if err != nil && !os.IsNotExist(err) {
log.Error("file remove: %s: %s", l.logFile+".1", err) log.Error("file remove: %s: %s", l.logFile+".1", err)
} }
err = os.Remove(l.logFile) err = os.Remove(l.logFile)
if err != nil { if err != nil && !os.IsNotExist(err) {
log.Error("file remove: %s: %s", l.logFile, err) log.Error("file remove: %s: %s", l.logFile, err)
} }

View File

@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"time"
"github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/log"
) )
@ -24,9 +25,10 @@ func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) {
if s.limit/24 > 7 { if s.limit/24 > 7 {
units = Days units = Days
} }
counter := log.StartTimer()
start := time.Now()
d := s.getData(units) d := s.getData(units)
counter.LogElapsed("Stats: prepared data") log.Debug("Stats: prepared data in %v", time.Since(start))
if d == nil { if d == nil {
httpError(r, w, http.StatusInternalServerError, "Couldn't get statistics data") httpError(r, w, http.StatusInternalServerError, "Couldn't get statistics data")