From 4ea93c4c9e27283d9a6c7e312f804006cf196412 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 28 Jan 2022 06:31:13 +0100 Subject: [PATCH] fix: add missing logging args and context In the log files, I sometimes see [*** LOG ERROR #0045 ***] [2021-10-27 02:42:31] [logger] {argument index out of range} which seems like it should be fixed by this change. I also added a [...] context everywhere that an exception message was just logged without context. --- player/cms/CollectionInterval.cpp | 2 +- player/cms/RequiredFilesDownloader.cpp | 2 +- player/common/logger/XmlLogsRetriever.cpp | 4 ++-- player/control/layout/LayoutsManager.cpp | 6 +++--- player/schedule/LayoutSchedule.cpp | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/player/cms/CollectionInterval.cpp b/player/cms/CollectionInterval.cpp index f4806d16b..a5e6f67b6 100644 --- a/player/cms/CollectionInterval.cpp +++ b/player/cms/CollectionInterval.cpp @@ -257,7 +257,7 @@ void CollectionInterval::submitStats() } catch (const std::exception& e) { - Log::error(e.what()); + Log::error("[CollectionInterval] {}", e.what()); Log::error("[CollectionInterval] Failed to submit stats"); } } diff --git a/player/cms/RequiredFilesDownloader.cpp b/player/cms/RequiredFilesDownloader.cpp index 2e96a3a83..97941356f 100644 --- a/player/cms/RequiredFilesDownloader.cpp +++ b/player/cms/RequiredFilesDownloader.cpp @@ -26,7 +26,7 @@ bool RequiredFilesDownloader::onRegularFileDownloaded(const ResponseContentResul } else { - Log::error("[{}] Download error: {}", file.name()); + Log::error("[{}] Download error: {}", file.name(), error); return false; } } diff --git a/player/common/logger/XmlLogsRetriever.cpp b/player/common/logger/XmlLogsRetriever.cpp index 660e0d0c8..192efcf5d 100644 --- a/player/common/logger/XmlLogsRetriever.cpp +++ b/player/common/logger/XmlLogsRetriever.cpp @@ -29,8 +29,8 @@ std::string XmlLogsRetriever::formatLogs(const std::string& logs) } catch (std::exception& e) { - Log::error("[XmlLogsRetriever] Format logs error: ", e.what()); - Log::trace(logs); + Log::error("[XmlLogsRetriever] Format logs error: {}", e.what()); + Log::trace("[XmlLogsRetriever] {}", logs); } return {}; diff --git a/player/control/layout/LayoutsManager.cpp b/player/control/layout/LayoutsManager.cpp index d30526eac..b381d9975 100644 --- a/player/control/layout/LayoutsManager.cpp +++ b/player/control/layout/LayoutsManager.cpp @@ -100,7 +100,7 @@ std::unique_ptr LayoutsManager::createLayout(int layoutId) } catch (const std::exception& e) { - Log::error(e.what()); + Log::error("[LayoutsManager] {}", e.what()); } }); layout->mediaStatsReady().connect([this, layoutId, scheduleId](const MediaPlayingTime& intervals) { @@ -115,7 +115,7 @@ std::unique_ptr LayoutsManager::createLayout(int layoutId) } catch (const std::exception& e) { - Log::error(e.what()); + Log::error("[LayoutsManager] {}", e.what()); } }); @@ -136,7 +136,7 @@ std::unique_ptr LayoutsManager::createLayout(int layoutId) } catch (std::exception& e) { - Log::error(e.what()); + Log::error("[LayoutsManager] {}", e.what()); Log::info("[LayoutsManager] Check resource folder to find out what happened"); } diff --git a/player/schedule/LayoutSchedule.cpp b/player/schedule/LayoutSchedule.cpp index dd17f3811..63ad7cb1d 100644 --- a/player/schedule/LayoutSchedule.cpp +++ b/player/schedule/LayoutSchedule.cpp @@ -16,7 +16,7 @@ LayoutSchedule LayoutSchedule::fromFile(const FilePath& path) } catch (std::exception& e) { - Log::error(e.what()); + Log::error("[LayoutSchedule] {}", e.what()); } return {}; } @@ -30,7 +30,7 @@ LayoutSchedule LayoutSchedule::fromString(const std::string& string) } catch (std::exception& e) { - Log::error(e.what()); + Log::error("[LayoutSchedule] {}", e.what()); } return {}; } @@ -44,7 +44,7 @@ void LayoutSchedule::toFile(const FilePath& path) const } catch (std::exception& e) { - Log::error(e.what()); + Log::error("[LayoutSchedule] {}", e.what()); } }