From ca6bd5bd639b66a64261bf45d9afcb61e0fcf75c Mon Sep 17 00:00:00 2001 From: serr Date: Sun, 8 Jun 2025 14:31:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=BE=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=20=D0=B2=20=D0=BA=D1=8D=D1=88=D0=B5=20=D1=82=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D1=83=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D1=80=D0=B0=D0=B7=20=D0=B2=20=D1=83=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9=20=D0=B2=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=84=D0=B8=D0=B3=D0=B5=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 11 +++++++++-- mvc/controllers/controllers_pages/main.go | 2 +- mvc/models/config.go | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 0449386..efa4762 100644 --- a/main.go +++ b/main.go @@ -40,8 +40,15 @@ func main() { // Сообщение в лог о количестве элементов в кэше tools.Ticker(func() { - log.Printf("Number of pages in cache: %d", len(app.PagesCache.Data)) - }, time.Minute*30) + log.Println("Pages in cache:") + if len(app.PagesCache.Data) != 0 { + for key := range app.PagesCache.Data { + log.Println(key) + } + } else { + log.Println("No pages in the cache") + } + }, time.Second*app.Cfg.CacheLogInterval) } // Запуск сервера diff --git a/mvc/controllers/controllers_pages/main.go b/mvc/controllers/controllers_pages/main.go index ed569e3..c2810f8 100644 --- a/mvc/controllers/controllers_pages/main.go +++ b/mvc/controllers/controllers_pages/main.go @@ -22,7 +22,7 @@ func MainPageHandler(app *models.App) http.HandlerFunc { // Количество запросов, обработанных сервером за 24ч if r.Method == "COUNT" { var count []byte - if count, err = tools.GetJournalctlLogsCount("server", app.Cfg.ServerDomain, 24); err != nil { + if count, err = tools.GetJournalctlLogsCount("server", "duration: ", 24); err != nil { log.Printf("%s", err.Error()) } sendCount(w, count) diff --git a/mvc/models/config.go b/mvc/models/config.go index 0925532..0c7b74a 100644 --- a/mvc/models/config.go +++ b/mvc/models/config.go @@ -25,6 +25,7 @@ type Config struct { LastFMUsername string LastFMToken string LastFMUpdateInterval time.Duration + CacheLogInterval time.Duration } func loadConfig(configPath string) (*Config, error) {