From 20b8c7523499b50b9fd3b0343445a2ceef2a22f6 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 13 Apr 2022 20:08:04 -0500 Subject: [PATCH 01/13] Initial setup for spdlog --- CMakeLists.txt | 1 + scwx-qt/source/scwx/qt/main/main.cpp | 5 ++++ wxdata/include/scwx/util/logger.hpp | 20 +++++++++++++++ wxdata/source/scwx/util/logger.cpp | 37 ++++++++++++++++++++++++++++ wxdata/wxdata.cmake | 4 +++ 5 files changed, 67 insertions(+) create mode 100644 wxdata/include/scwx/util/logger.hpp create mode 100644 wxdata/source/scwx/util/logger.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 41a23cdb..8717a376 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ conan_cmake_configure(REQUIRES boost/1.78.0 glm/0.9.9.8 gtest/cci.20210126 openssl/1.1.1n + spdlog/1.10.0 vulkan-loader/1.3.204.1 GENERATORS cmake cmake_find_package diff --git a/scwx-qt/source/scwx/qt/main/main.cpp b/scwx-qt/source/scwx/qt/main/main.cpp index 56b9ffe1..0bb745b8 100644 --- a/scwx-qt/source/scwx/qt/main/main.cpp +++ b/scwx-qt/source/scwx/qt/main/main.cpp @@ -2,9 +2,11 @@ #include #include #include +#include #include #include +#include #include int main(int argc, char* argv[]) @@ -12,6 +14,9 @@ int main(int argc, char* argv[]) boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug); + scwx::util::Logger::Initialize(); + spdlog::set_level(spdlog::level::debug); + QCoreApplication::setApplicationName("Supercell Wx"); scwx::qt::config::RadarSite::Initialize(); diff --git a/wxdata/include/scwx/util/logger.hpp b/wxdata/include/scwx/util/logger.hpp new file mode 100644 index 00000000..b9c4442e --- /dev/null +++ b/wxdata/include/scwx/util/logger.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +#include + +namespace scwx +{ +namespace util +{ +namespace Logger +{ + +void Initialize(); +std::shared_ptr Create(const std::string& name); + +} // namespace Logger +} // namespace util +} // namespace scwx diff --git a/wxdata/source/scwx/util/logger.cpp b/wxdata/source/scwx/util/logger.cpp new file mode 100644 index 00000000..0642dfe0 --- /dev/null +++ b/wxdata/source/scwx/util/logger.cpp @@ -0,0 +1,37 @@ +#include + +#include + +#include +#include + +namespace scwx +{ +namespace util +{ +namespace Logger +{ + +void Initialize() +{ + spdlog::set_pattern("[%Y-%m-%d %T.%e] [%t] [%^%l%$] [%n] %v"); +} + +std::shared_ptr Create(const std::string& name) +{ + // Create a shared sink + static auto sink = std::make_shared(); + + // Create the logger + std::shared_ptr logger = + std::make_shared(name, sink); + + // Register the logger, so it can be retrieved later using spdlog::get() + spdlog::register_logger(logger); + + return logger; +} + +} // namespace Logger +} // namespace util +} // namespace scwx diff --git a/wxdata/wxdata.cmake b/wxdata/wxdata.cmake index e23ef30e..ec82c5b6 100644 --- a/wxdata/wxdata.cmake +++ b/wxdata/wxdata.cmake @@ -1,6 +1,7 @@ project(scwx-data) find_package(Boost) +find_package(spdlog) set(HDR_AWIPS include/scwx/awips/coded_location.hpp include/scwx/awips/coded_time_motion_location.hpp @@ -34,12 +35,14 @@ set(SRC_COMMON source/scwx/common/color_table.cpp source/scwx/common/vcp.cpp) set(HDR_UTIL include/scwx/util/float.hpp include/scwx/util/iterator.hpp + include/scwx/util/logger.hpp include/scwx/util/rangebuf.hpp include/scwx/util/streams.hpp include/scwx/util/threads.hpp include/scwx/util/time.hpp include/scwx/util/vectorbuf.hpp) set(SRC_UTIL source/scwx/util/float.cpp + source/scwx/util/logger.cpp source/scwx/util/rangebuf.cpp source/scwx/util/streams.cpp source/scwx/util/time.cpp @@ -191,6 +194,7 @@ if(MSVC) target_compile_options(wxdata PRIVATE /W3) endif() +target_link_libraries(wxdata PUBLIC spdlog::spdlog) target_link_libraries(wxdata INTERFACE Boost::iostreams Boost::log BZip2::BZip2 From 3d162f03366876dbb22be88cbbbdf6be4bd7314d Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 13 Apr 2022 20:09:00 -0500 Subject: [PATCH 02/13] Update main_window.cpp to use spdlog instead of boost log --- scwx-qt/source/scwx/qt/main/main_window.cpp | 18 ++++++++---------- scwx-qt/ts/scwx_en_US.ts | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index fd237a56..cef54578 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -17,8 +18,6 @@ #include #include -#include - namespace scwx { namespace qt @@ -26,7 +25,8 @@ namespace qt namespace main { -static const std::string logPrefix_ = "[scwx::qt::main::main_window] "; +static const std::string logPrefix_ = "scwx::qt::main::main_window"; +static const auto logger_ = util::Logger::Create(logPrefix_); class MainWindowImpl : public QObject { @@ -51,10 +51,9 @@ public: { if (!std::filesystem::create_directories(appDataPath)) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ - << "Unable to create application local data directory: \"" - << appDataPath << "\""; + logger_->error( + "Unable to create application local data directory: \"{}\"", + appDataPath); } } @@ -253,7 +252,7 @@ void MainWindow::on_actionOpen_triggered() this, [=](const QString& file) { - BOOST_LOG_TRIVIAL(info) << "Selected: " << file.toStdString(); + logger_->info("Selected: {}", file.toStdString()); std::shared_ptr request = std::make_shared(); @@ -397,8 +396,7 @@ void MainWindowImpl::SelectRadarProduct(map::MapWidget* mapWidget, { const std::string& productName = common::GetLevel2Name(product); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Selecting Level 2 radar product: " << productName; + logger_->debug("Selecting Level 2 radar product: {}", productName); if (mapWidget == activeMap_) { diff --git a/scwx-qt/ts/scwx_en_US.ts b/scwx-qt/ts/scwx_en_US.ts index 35c2eac2..925f53ac 100644 --- a/scwx-qt/ts/scwx_en_US.ts +++ b/scwx-qt/ts/scwx_en_US.ts @@ -102,7 +102,7 @@ scwx::qt::main::MainWindow - + Unrecognized NEXRAD Product: From 44bcc7dd4ce91d402a49bea874ffde79831c950b Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sat, 16 Apr 2022 07:48:49 -0500 Subject: [PATCH 03/13] Boost.Log -> spdlog - awips and common --- wxdata/source/scwx/awips/coded_location.cpp | 35 ++++++++-------- .../scwx/awips/coded_time_motion_location.cpp | 41 ++++++++----------- wxdata/source/scwx/awips/message.cpp | 23 +++++------ wxdata/source/scwx/awips/phenomenon.cpp | 8 ++-- wxdata/source/scwx/awips/pvtec.cpp | 20 ++++----- wxdata/source/scwx/awips/significance.cpp | 8 ++-- .../source/scwx/awips/text_product_file.cpp | 13 +++--- .../scwx/awips/text_product_message.cpp | 4 +- wxdata/source/scwx/awips/wmo_header.cpp | 22 +++++----- wxdata/source/scwx/common/color_table.cpp | 11 +++-- 10 files changed, 82 insertions(+), 103 deletions(-) diff --git a/wxdata/source/scwx/awips/coded_location.cpp b/wxdata/source/scwx/awips/coded_location.cpp index f6ff067a..fb93b9fb 100644 --- a/wxdata/source/scwx/awips/coded_location.cpp +++ b/wxdata/source/scwx/awips/coded_location.cpp @@ -1,15 +1,15 @@ #include +#include #include -#include - namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::coded_location] "; +static const std::string logPrefix_ = "scwx::awips::coded_location"; +static const auto logger_ = util::Logger::Create(logPrefix_); class CodedLocationImpl { @@ -93,9 +93,8 @@ bool CodedLocation::Parse(const StringRange& lines, const std::string& wfo) } catch (const std::exception& ex) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid WFO location token: \"" << *token - << "\" (" << ex.what() << ")"; + logger_->warn( + "Invalid WFO location token: \"{}\" ({})", *token, ex.what()); dataValid = false; break; } @@ -128,10 +127,8 @@ bool CodedLocation::Parse(const StringRange& lines, const std::string& wfo) { if (token->size() != 8) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid National Center LAT...LON format: \"" << *token - << "\""; + logger_->warn("Invalid National Center LAT...LON format: \"{}\"", + *token); dataValid = false; break; @@ -147,9 +144,10 @@ bool CodedLocation::Parse(const StringRange& lines, const std::string& wfo) } catch (const std::exception& ex) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid National Center location token: \"" - << *token << "\" (" << ex.what() << ")"; + logger_->warn( + "Invalid National Center location token: \"{}\" ({})", + *token, + ex.what()); dataValid = false; break; } @@ -174,18 +172,17 @@ bool CodedLocation::Parse(const StringRange& lines, const std::string& wfo) { if (tokenList.empty()) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "LAT...LON not found"; + logger_->warn("LAT...LON not found"); } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Malformed LAT...LON tokens: (0: " << tokenList.at(0) - << ", size: " << tokenList.size() << ")"; + logger_->warn("Malformed LAT...LON tokens: (0: {}, size: {})", + tokenList.at(0), + tokenList.size()); for (const auto& token : tokenList) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << token; + logger_->debug("{}", token); } } diff --git a/wxdata/source/scwx/awips/coded_time_motion_location.cpp b/wxdata/source/scwx/awips/coded_time_motion_location.cpp index e3f94bea..f5b5a4ab 100644 --- a/wxdata/source/scwx/awips/coded_time_motion_location.cpp +++ b/wxdata/source/scwx/awips/coded_time_motion_location.cpp @@ -4,18 +4,17 @@ #endif #include +#include #include -#include - namespace scwx { namespace awips { -static const std::string logPrefix_ = - "[scwx::awips::coded_time_motion_location] "; +static const std::string logPrefix_ = "scwx::awips::coded_time_motion_location"; +static const auto logger_ = util::Logger::Create(logPrefix_); class CodedTimeMotionLocationImpl { @@ -111,8 +110,7 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid time: \"" << time << "\""; + logger_->warn("Invalid time: \"{}\"", time); p->time_ = hh_mm_ss {}; dataValid = false; } @@ -129,16 +127,14 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, } catch (const std::exception& ex) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid direction: \"" << direction << "\" (" - << ex.what() << ")"; + logger_->warn( + "Invalid direction: \"{}\" ({})", direction, ex.what()); dataValid = false; } } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid direction: \"" << direction << "\""; + logger_->warn("Invalid direction: \"{}\"", direction); dataValid = false; } @@ -153,15 +149,13 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, } catch (const std::exception& ex) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Invalid speed: \"" - << speed << "\" (" << ex.what() << ")"; + logger_->warn("Invalid speed: \"{}\" ({})", speed, ex.what()); dataValid = false; } } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid speed: \"" << speed << "\""; + logger_->warn("Invalid speed: \"{}\"", speed); dataValid = false; } @@ -180,9 +174,8 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, } catch (const std::exception& ex) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid location token: \"" << *token << "\" (" - << ex.what() << ")"; + logger_->warn( + "Invalid location token: \"{}\" ({})", *token, ex.what()); dataValid = false; break; } @@ -212,19 +205,17 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, { if (tokenList.empty()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "TIME...MOT...LOC not found"; + logger_->warn("TIME...MOT...LOC not found"); } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Malformed TIME...MOT...LOC tokens: (0: " << tokenList.at(0) - << ", size: " << tokenList.size() << ")"; + logger_->warn("Malformed TIME...MOT...LOC tokens: (0: {}, size: {})", + tokenList.at(0), + tokenList.size()); for (const auto& token : tokenList) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << token; + logger_->debug("{}", token); } } diff --git a/wxdata/source/scwx/awips/message.cpp b/wxdata/source/scwx/awips/message.cpp index 23005396..73ae88a2 100644 --- a/wxdata/source/scwx/awips/message.cpp +++ b/wxdata/source/scwx/awips/message.cpp @@ -1,13 +1,13 @@ #include - -#include +#include namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::message] "; +static const std::string logPrefix_ = "scwx::awips::message"; +static const auto logger_ = util::Logger::Create(logPrefix_); class MessageImpl { @@ -30,13 +30,12 @@ bool Message::ValidateMessage(std::istream& is, size_t bytesRead) const if (is.eof()) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Reached end of data stream"; + logger_->warn("Reached end of data stream"); messageValid = false; } else if (is.fail()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not read from input stream"; + logger_->warn("Could not read from input stream"); messageValid = false; } else if (bytesRead != dataSize) @@ -47,15 +46,15 @@ bool Message::ValidateMessage(std::istream& is, size_t bytesRead) const if (bytesRead < dataSize) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Message contents smaller than size: " << bytesRead - << " < " << dataSize << " bytes"; + logger_->trace("Message contents smaller than size: {} < {} bytes", + bytesRead, + dataSize); } if (bytesRead > dataSize) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Message contents larger than size: " << bytesRead - << " > " << dataSize << " bytes"; + logger_->warn("Message contents larger than size: {} > {} bytes", + bytesRead, + dataSize); messageValid = false; } } diff --git a/wxdata/source/scwx/awips/phenomenon.cpp b/wxdata/source/scwx/awips/phenomenon.cpp index ea97fe3f..ee8e549d 100644 --- a/wxdata/source/scwx/awips/phenomenon.cpp +++ b/wxdata/source/scwx/awips/phenomenon.cpp @@ -1,16 +1,17 @@ #include +#include #include #include #include -#include namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::phenomenon] "; +static const std::string logPrefix_ = "scwx::awips::phenomenon"; +static const auto logger_ = util::Logger::Create(logPrefix_); typedef boost::bimap, boost::bimaps::unordered_set_of> @@ -147,8 +148,7 @@ Phenomenon GetPhenomenon(const std::string& code) { phenomenon = Phenomenon::Unknown; - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Unrecognized code: \"" << code << "\""; + logger_->debug("Unrecognized code: \"{}\"", code); } return phenomenon; diff --git a/wxdata/source/scwx/awips/pvtec.cpp b/wxdata/source/scwx/awips/pvtec.cpp index e8987052..1e8ded8d 100644 --- a/wxdata/source/scwx/awips/pvtec.cpp +++ b/wxdata/source/scwx/awips/pvtec.cpp @@ -4,20 +4,21 @@ #endif #include +#include #include #include #include #include -#include namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::pvtec] "; +static const std::string logPrefix_ = "scwx::awips::pvtec"; +static const auto logger_ = util::Logger::Create(logPrefix_); typedef boost::bimap, boost::bimaps::unordered_set_of> @@ -171,9 +172,9 @@ bool PVtec::Parse(const std::string& s) } catch (const std::exception& ex) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Error parsing event tracking number: \"" - << eventNumberString << "\" (" << ex.what() << ")"; + logger_->warn("Error parsing event tracking number: \"{}\" ({})", + eventNumberString, + ex.what()); p->eventTrackingNumber_ = -1; } @@ -214,8 +215,7 @@ bool PVtec::Parse(const std::string& s) } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid P-VTEC: \"" << s << "\""; + logger_->warn("Invalid P-VTEC: \"{}\"", s); } p->valid_ = dataValid; @@ -235,8 +235,7 @@ PVtec::ProductType PVtec::GetProductType(const std::string& code) { productType = ProductType::Unknown; - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Unrecognized product code: \"" << code << "\""; + logger_->debug("Unrecognized product code: \"{}\"", code); } return productType; @@ -259,8 +258,7 @@ PVtec::Action PVtec::GetAction(const std::string& code) { action = Action::Unknown; - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Unrecognized action code: \"" << code << "\""; + logger_->debug("Unrecognized action code: \"{}\"", code); } return action; diff --git a/wxdata/source/scwx/awips/significance.cpp b/wxdata/source/scwx/awips/significance.cpp index 0be08056..6d1d8671 100644 --- a/wxdata/source/scwx/awips/significance.cpp +++ b/wxdata/source/scwx/awips/significance.cpp @@ -1,16 +1,17 @@ #include +#include #include #include #include -#include namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::significance] "; +static const std::string logPrefix_ = "scwx::awips::significance"; +static const auto logger_ = util::Logger::Create(logPrefix_); typedef boost::bimap, boost::bimaps::unordered_set_of> @@ -49,8 +50,7 @@ Significance GetSignificance(const std::string& code) { significance = Significance::Unknown; - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Unrecognized code: \"" << code << "\""; + logger_->debug("Unrecognized code: \"{}\"", code); } return significance; diff --git a/wxdata/source/scwx/awips/text_product_file.cpp b/wxdata/source/scwx/awips/text_product_file.cpp index 724c258c..1e738ef6 100644 --- a/wxdata/source/scwx/awips/text_product_file.cpp +++ b/wxdata/source/scwx/awips/text_product_file.cpp @@ -1,15 +1,15 @@ #include +#include #include -#include - namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::text_product_file] "; +static const std::string logPrefix_ = "scwx::awips::text_product_file"; +static const auto logger_ = util::Logger::Create(logPrefix_); class TextProductFileImpl { @@ -41,14 +41,13 @@ std::shared_ptr TextProductFile::message(size_t i) const bool TextProductFile::LoadFile(const std::string& filename) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")"; + logger_->debug("LoadFile: {}", filename); bool fileValid = true; std::ifstream f(filename, std::ios_base::in | std::ios_base::binary); if (!f.good()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not open file for reading: " << filename; + logger_->warn("Could not open file for reading: {}", filename); fileValid = false; } @@ -62,7 +61,7 @@ bool TextProductFile::LoadFile(const std::string& filename) bool TextProductFile::LoadData(std::istream& is) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Data"; + logger_->debug("Loading Data"); while (!is.eof()) { diff --git a/wxdata/source/scwx/awips/text_product_message.cpp b/wxdata/source/scwx/awips/text_product_message.cpp index c6250041..f5753a8a 100644 --- a/wxdata/source/scwx/awips/text_product_message.cpp +++ b/wxdata/source/scwx/awips/text_product_message.cpp @@ -9,14 +9,12 @@ #include #include -#include - namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::text_product_message] "; +static const std::string logPrefix_ = "scwx::awips::text_product_message"; // Issuance date/time takes one of the following forms: // * _xM__day_mon_
_year diff --git a/wxdata/source/scwx/awips/wmo_header.cpp b/wxdata/source/scwx/awips/wmo_header.cpp index 04a98192..6fa813cc 100644 --- a/wxdata/source/scwx/awips/wmo_header.cpp +++ b/wxdata/source/scwx/awips/wmo_header.cpp @@ -1,12 +1,11 @@ #include +#include #include #include #include #include -#include - #ifdef WIN32 # include #else @@ -18,7 +17,8 @@ namespace scwx namespace awips { -static const std::string logPrefix_ = "[scwx::awips::wmo_header] "; +static const std::string logPrefix_ = "scwx::awips::wmo_header"; +static const auto logger_ = util::Logger::Create(logPrefix_); class WmoHeaderImpl { @@ -139,7 +139,7 @@ bool WmoHeader::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); headerValid = false; } else @@ -176,29 +176,28 @@ bool WmoHeader::Parse(std::istream& is) if (wmoTokenList.size() < 3 || wmoTokenList.size() > 4) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Invalid number of WMO tokens"; + logger_->debug("Invalid number of WMO tokens"); headerValid = false; } else if (wmoTokenList[0].size() != 6) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "WMO identifier malformed"; + logger_->debug("WMO identifier malformed"); headerValid = false; } else if (wmoTokenList[1].size() != 4) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ICAO malformed"; + logger_->debug("ICAO malformed"); headerValid = false; } else if (wmoTokenList[2].size() != 6) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Date/time malformed"; + logger_->debug("Date/time malformed"); headerValid = false; } else if (wmoTokenList.size() == 4 && wmoTokenList[3].size() != 3) { // BBB indicator is optional - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "BBB indicator malformed"; + logger_->debug("BBB indicator malformed"); headerValid = false; } else @@ -227,8 +226,7 @@ bool WmoHeader::Parse(std::istream& is) { if (awipsLine.size() != 6) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "AWIPS Identifier Line bad size"; + logger_->debug("AWIPS Identifier Line bad size"); headerValid = false; } else diff --git a/wxdata/source/scwx/common/color_table.cpp b/wxdata/source/scwx/common/color_table.cpp index e24cb8eb..48d9f0ea 100644 --- a/wxdata/source/scwx/common/color_table.cpp +++ b/wxdata/source/scwx/common/color_table.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -9,7 +10,6 @@ #include #include -#include #include @@ -18,7 +18,8 @@ namespace scwx namespace common { -static const std::string logPrefix_ {"[scwx::common::color_table] "}; +static const std::string logPrefix_ {"scwx::common::color_table"}; +static const auto logger_ = util::Logger::Create(logPrefix_); enum class ColorMode { @@ -135,8 +136,7 @@ bool ColorTable::IsValid() const std::shared_ptr ColorTable::Load(const std::string& filename) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Loading color table: " << filename; + logger_->debug("Loading color table: {}", filename); std::shared_ptr p = std::make_shared(); @@ -167,8 +167,7 @@ std::shared_ptr ColorTable::Load(const std::string& filename) } catch (const std::exception&) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not parse line: " << line; + logger_->warn("Could not parse line: {}", line); } } } From dda71133e07e43f596e9af675355fa5ba1e6392e Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sat, 16 Apr 2022 08:12:49 -0500 Subject: [PATCH 04/13] Boost.Log -> spdlog - wsr88d/rda --- .../wsr88d/rda/clutter_filter_bypass_map.cpp | 20 +++----- .../scwx/wsr88d/rda/clutter_filter_map.cpp | 31 +++++------- .../scwx/wsr88d/rda/digital_radar_data.cpp | 45 ++++++++--------- .../source/scwx/wsr88d/rda/level2_message.cpp | 4 +- .../wsr88d/rda/level2_message_factory.cpp | 28 +++++------ .../scwx/wsr88d/rda/level2_message_header.cpp | 28 +++++------ .../rda/performance_maintenance_data.cpp | 9 ++-- .../scwx/wsr88d/rda/rda_adaptation_data.cpp | 10 ++-- .../scwx/wsr88d/rda/rda_status_data.cpp | 9 ++-- .../rda/volume_coverage_pattern_data.cpp | 49 +++++++++++-------- 10 files changed, 105 insertions(+), 128 deletions(-) diff --git a/wxdata/source/scwx/wsr88d/rda/clutter_filter_bypass_map.cpp b/wxdata/source/scwx/wsr88d/rda/clutter_filter_bypass_map.cpp index cfc1c5aa..c0e8a7f9 100644 --- a/wxdata/source/scwx/wsr88d/rda/clutter_filter_bypass_map.cpp +++ b/wxdata/source/scwx/wsr88d/rda/clutter_filter_bypass_map.cpp @@ -1,9 +1,8 @@ #include +#include #include -#include - namespace scwx { namespace wsr88d @@ -12,7 +11,8 @@ namespace rda { static const std::string logPrefix_ = - "[scwx::wsr88d::rda::clutter_filter_bypass_map] "; + "scwx::wsr88d::rda::clutter_filter_bypass_map"; +static const auto logger_ = util::Logger::Create(logPrefix_); class ClutterFilterBypassMapImpl { @@ -61,8 +61,7 @@ ClutterFilterBypassMap::range_bin(uint16_t e, uint16_t r, uint16_t b) const bool ClutterFilterBypassMap::Parse(std::istream& is) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Parsing Clutter Filter Bypass Map (Message Type 13)"; + logger_->trace("Parsing Clutter Filter Bypass Map (Message Type 13)"); bool messageValid = true; size_t bytesRead = 0; @@ -79,21 +78,18 @@ bool ClutterFilterBypassMap::Parse(std::istream& is) if (p->mapGenerationDate_ < 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid date: " << p->mapGenerationDate_; + logger_->warn("Invalid date: {}", p->mapGenerationDate_); messageValid = false; } if (p->mapGenerationTime_ > 1440) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid time: " << p->mapGenerationTime_; + logger_->warn("Invalid time: {}", p->mapGenerationTime_); messageValid = false; } if (numElevationSegments < 1 || numElevationSegments > 5) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of elevation segments: " << numElevationSegments; + logger_->warn("Invalid number of elevation segments: {}", + numElevationSegments); messageValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rda/clutter_filter_map.cpp b/wxdata/source/scwx/wsr88d/rda/clutter_filter_map.cpp index 6433d70b..fdc062d4 100644 --- a/wxdata/source/scwx/wsr88d/rda/clutter_filter_map.cpp +++ b/wxdata/source/scwx/wsr88d/rda/clutter_filter_map.cpp @@ -1,9 +1,8 @@ #include +#include #include -#include - namespace scwx { namespace wsr88d @@ -11,8 +10,8 @@ namespace wsr88d namespace rda { -static const std::string logPrefix_ = - "[scwx::wsr88d::rda::clutter_filter_map] "; +static const std::string logPrefix_ = "scwx::wsr88d::rda::clutter_filter_map"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct RangeZone { @@ -75,8 +74,7 @@ uint16_t ClutterFilterMap::end_range(uint16_t e, uint16_t a, uint16_t z) const bool ClutterFilterMap::Parse(std::istream& is) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Parsing Clutter Filter Map (Message Type 15)"; + logger_->trace("Parsing Clutter Filter Map (Message Type 15)"); bool messageValid = true; size_t bytesRead = 0; @@ -93,21 +91,18 @@ bool ClutterFilterMap::Parse(std::istream& is) if (p->mapGenerationDate_ < 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid date: " << p->mapGenerationDate_; + logger_->warn("Invalid date: {}", p->mapGenerationDate_); messageValid = false; } if (p->mapGenerationTime_ > 1440) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid time: " << p->mapGenerationTime_; + logger_->warn("Invalid time: {}", p->mapGenerationTime_); messageValid = false; } if (numElevationSegments < 1 || numElevationSegments > 5) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of elevation segments: " << numElevationSegments; + logger_->warn("Invalid number of elevation segments: {}", + numElevationSegments); messageValid = false; } @@ -132,9 +127,7 @@ bool ClutterFilterMap::Parse(std::istream& is) if (numRangeZones < 1 || numRangeZones > 20) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of range zones: " << numRangeZones; + logger_->warn("Invalid number of range zones: {}", numRangeZones); messageValid = false; } @@ -158,14 +151,12 @@ bool ClutterFilterMap::Parse(std::istream& is) if (zone.opCode > 2) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid op code: " << zone.opCode; + logger_->warn("Invalid op code: {}", zone.opCode); messageValid = false; } if (zone.endRange > 511) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid end range: " << zone.endRange; + logger_->warn("Invalid end range: {}", zone.endRange); messageValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rda/digital_radar_data.cpp b/wxdata/source/scwx/wsr88d/rda/digital_radar_data.cpp index 586cf40c..4fc02e7c 100644 --- a/wxdata/source/scwx/wsr88d/rda/digital_radar_data.cpp +++ b/wxdata/source/scwx/wsr88d/rda/digital_radar_data.cpp @@ -1,6 +1,5 @@ #include - -#include +#include namespace scwx { @@ -9,8 +8,8 @@ namespace wsr88d namespace rda { -static const std::string logPrefix_ = - "[scwx::wsr88d::rda::digital_radar_data] "; +static const std::string logPrefix_ = "scwx::wsr88d::rda::digital_radar_data"; +static const auto logger_ = util::Logger::Create(logPrefix_); static const std::unordered_map strToDataBlock_ { {"VOL", DataBlockType::Volume}, @@ -145,9 +144,15 @@ const void* MomentDataBlock::data_moments() const switch (p->dataWordSize_) { - case 8: dataMoments = p->momentGates8_.data(); break; - case 16: dataMoments = p->momentGates16_.data(); break; - default: dataMoments = nullptr; break; + case 8: + dataMoments = p->momentGates8_.data(); + break; + case 16: + dataMoments = p->momentGates16_.data(); + break; + default: + dataMoments = nullptr; + break; } return dataMoments; @@ -210,16 +215,14 @@ bool MomentDataBlock::Parse(std::istream& is) } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid data word size: " << p->dataWordSize_; + logger_->warn("Invalid data word size: {}", p->dataWordSize_); dataBlockValid = false; } } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of data moment gates: " - << p->numberOfDataMomentGates_; + logger_->warn("Invalid number of data moment gates: {}", + p->numberOfDataMomentGates_); dataBlockValid = false; } @@ -657,8 +660,7 @@ DigitalRadarData::moment_data_block(DataBlockType type) const bool DigitalRadarData::Parse(std::istream& is) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Parsing Digital Radar Data (Message Type 31)"; + logger_->trace("Parsing Digital Radar Data (Message Type 31)"); bool messageValid = true; size_t bytesRead = 0; @@ -694,26 +696,22 @@ bool DigitalRadarData::Parse(std::istream& is) if (p->azimuthNumber_ < 1 || p->azimuthNumber_ > 720) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid azimuth number: " << p->azimuthNumber_; + logger_->warn("Invalid azimuth number: {}", p->azimuthNumber_); messageValid = false; } if (p->elevationNumber_ < 1 || p->elevationNumber_ > 32) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid elevation number: " << p->elevationNumber_; + logger_->warn("Invalid elevation number: ", p->elevationNumber_); messageValid = false; } if (p->dataBlockCount_ < 4 || p->dataBlockCount_ > 10) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of data blocks: " << p->dataBlockCount_; + logger_->warn("Invalid number of data blocks: {}", p->dataBlockCount_); messageValid = false; } if (p->compressionIndicator_ != 0) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Compression not supported"; + logger_->warn("Compression not supported"); messageValid = false; } @@ -772,8 +770,7 @@ bool DigitalRadarData::Parse(std::istream& is) std::move(MomentDataBlock::Create(dataBlockType, dataName, is)); break; default: - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Unknown data name: " << dataName; + logger_->warn("Unknown data name: {}", dataName); break; } } diff --git a/wxdata/source/scwx/wsr88d/rda/level2_message.cpp b/wxdata/source/scwx/wsr88d/rda/level2_message.cpp index 6336a1c5..f7603b12 100644 --- a/wxdata/source/scwx/wsr88d/rda/level2_message.cpp +++ b/wxdata/source/scwx/wsr88d/rda/level2_message.cpp @@ -1,7 +1,5 @@ #include -#include - namespace scwx { namespace wsr88d @@ -9,7 +7,7 @@ namespace wsr88d namespace rda { -static const std::string logPrefix_ = "[scwx::wsr88d::rda::level2_message] "; +static const std::string logPrefix_ = "scwx::wsr88d::rda::level2_message"; class Level2MessageImpl { diff --git a/wxdata/source/scwx/wsr88d/rda/level2_message_factory.cpp b/wxdata/source/scwx/wsr88d/rda/level2_message_factory.cpp index 595593ca..f56df578 100644 --- a/wxdata/source/scwx/wsr88d/rda/level2_message_factory.cpp +++ b/wxdata/source/scwx/wsr88d/rda/level2_message_factory.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -12,8 +13,6 @@ #include #include -#include - namespace scwx { namespace wsr88d @@ -22,7 +21,8 @@ namespace rda { static const std::string logPrefix_ = - "[scwx::wsr88d::rda::level2_message_factory] "; + "scwx::wsr88d::rda::level2_message_factory"; +static const auto logger_ = util::Logger::Create(logPrefix_); typedef std::function(Level2MessageHeader&&, std::istream&)> @@ -51,9 +51,8 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream& is) if (info.headerValid && create_.find(header.message_type()) == create_.end()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Unknown message type: " - << static_cast(header.message_type()); + logger_->warn("Unknown message type: {}", + static_cast(header.message_type())); info.messageValid = false; } @@ -68,16 +67,15 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream& is) if (totalSegments == 1) { - BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Found Message " - << static_cast(messageType); + logger_->trace("Found Message {}", static_cast(messageType)); messageStream = &is; } else { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Found Message " - << static_cast(messageType) << " Segment " << segment - << "/" << totalSegments; + logger_->trace("Found Message {} Segment {}/{}", + static_cast(messageType), + segment, + totalSegments); if (segment == 1) { @@ -89,8 +87,7 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream& is) if (messageData_.capacity() < bufferedSize_ + dataSize) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Bad size estimate, increasing size"; + logger_->debug("Bad size estimate, increasing size"); // Estimate remaining size uint16_t remainingSegments = @@ -105,8 +102,7 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "End of file reached trying to buffer message"; + logger_->warn("End of file reached trying to buffer message"); info.messageValid = false; messageData_.shrink_to_fit(); bufferedSize_ = 0; diff --git a/wxdata/source/scwx/wsr88d/rda/level2_message_header.cpp b/wxdata/source/scwx/wsr88d/rda/level2_message_header.cpp index e1ef2f8b..b1309ee3 100644 --- a/wxdata/source/scwx/wsr88d/rda/level2_message_header.cpp +++ b/wxdata/source/scwx/wsr88d/rda/level2_message_header.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - #ifdef WIN32 # include #else @@ -19,7 +18,8 @@ namespace rda { static const std::string logPrefix_ = - "[scwx::wsr88d::rda::level2_message_header] "; + "scwx::wsr88d::rda::level2_message_header"; +static const auto logger_ = util::Logger::Create(logPrefix_); class Level2MessageHeaderImpl { @@ -123,44 +123,40 @@ bool Level2MessageHeader::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); headerValid = false; } else { if (p->messageSize_ < 9) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid message size: " << p->messageSize_; + logger_->warn("Invalid message size: {}", p->messageSize_); headerValid = false; } if (p->julianDate_ < 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid date: " << p->julianDate_; + logger_->warn("Invalid date: {}", p->julianDate_); headerValid = false; } if (p->millisecondsOfDay_ > 86'399'999u) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid milliseconds: " << p->millisecondsOfDay_; + logger_->warn("Invalid milliseconds: {}", p->millisecondsOfDay_); headerValid = false; } if (p->messageSize_ < 65534 && p->messageSegmentNumber_ > p->numberOfMessageSegments_) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid segment = " << p->messageSegmentNumber_ - << "/" << p->numberOfMessageSegments_; + logger_->warn("Invalid segment = {}/{}", + p->messageSegmentNumber_, + p->numberOfMessageSegments_); headerValid = false; } } if (headerValid) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ - << "Message type: " << static_cast(p->messageType_); + logger_->trace("Message type: {}", + static_cast(p->messageType_)); } return headerValid; diff --git a/wxdata/source/scwx/wsr88d/rda/performance_maintenance_data.cpp b/wxdata/source/scwx/wsr88d/rda/performance_maintenance_data.cpp index e811d78b..662ab506 100644 --- a/wxdata/source/scwx/wsr88d/rda/performance_maintenance_data.cpp +++ b/wxdata/source/scwx/wsr88d/rda/performance_maintenance_data.cpp @@ -1,9 +1,8 @@ #include +#include #include -#include - namespace scwx { namespace wsr88d @@ -12,7 +11,8 @@ namespace rda { static const std::string logPrefix_ = - "[scwx::wsr88d::rda::performance_maintenance_data] "; + "scwx::wsr88d::rda::performance_maintenance_data"; +static const auto logger_ = util::Logger::Create(logPrefix_); class PerformanceMaintenanceDataImpl { @@ -1823,8 +1823,7 @@ uint16_t PerformanceMaintenanceData::version() const bool PerformanceMaintenanceData::Parse(std::istream& is) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Parsing Performance/Maintenance Data (Message Type 3)"; + logger_->trace("Parsing Performance/Maintenance Data (Message Type 3)"); bool messageValid = true; size_t bytesRead = 0; diff --git a/wxdata/source/scwx/wsr88d/rda/rda_adaptation_data.cpp b/wxdata/source/scwx/wsr88d/rda/rda_adaptation_data.cpp index dd21c415..94a96283 100644 --- a/wxdata/source/scwx/wsr88d/rda/rda_adaptation_data.cpp +++ b/wxdata/source/scwx/wsr88d/rda/rda_adaptation_data.cpp @@ -1,6 +1,5 @@ #include - -#include +#include namespace scwx { @@ -9,8 +8,8 @@ namespace wsr88d namespace rda { -static const std::string logPrefix_ = - "[scwx::wsr88d::rda::rda_adaptation_data] "; +static const std::string logPrefix_ = "scwx::wsr88d::rda::rda_adaptation_data"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct AntManualSetup { @@ -1267,8 +1266,7 @@ float RdaAdaptationData::txb_alarm_thresh() const bool RdaAdaptationData::Parse(std::istream& is) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Parsing RDA Adaptation Data (Message Type 18)"; + logger_->trace("Parsing RDA Adaptation Data (Message Type 18)"); bool messageValid = true; size_t bytesRead = 0; diff --git a/wxdata/source/scwx/wsr88d/rda/rda_status_data.cpp b/wxdata/source/scwx/wsr88d/rda/rda_status_data.cpp index 3b219feb..ced8ff59 100644 --- a/wxdata/source/scwx/wsr88d/rda/rda_status_data.cpp +++ b/wxdata/source/scwx/wsr88d/rda/rda_status_data.cpp @@ -1,6 +1,5 @@ #include - -#include +#include namespace scwx { @@ -9,7 +8,8 @@ namespace wsr88d namespace rda { -static const std::string logPrefix_ = "[scwx::wsr88d::rda::rda_status_data] "; +static const std::string logPrefix_ = "scwx::wsr88d::rda::rda_status_data"; +static const auto logger_ = util::Logger::Create(logPrefix_); class RdaStatusDataImpl { @@ -233,8 +233,7 @@ uint16_t RdaStatusData::status_version() const bool RdaStatusData::Parse(std::istream& is) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Parsing RDA Status Data (Message Type 2)"; + logger_->trace("Parsing RDA Status Data (Message Type 2)"); bool messageValid = true; size_t bytesRead = 0; diff --git a/wxdata/source/scwx/wsr88d/rda/volume_coverage_pattern_data.cpp b/wxdata/source/scwx/wsr88d/rda/volume_coverage_pattern_data.cpp index 64e9fd0a..72943869 100644 --- a/wxdata/source/scwx/wsr88d/rda/volume_coverage_pattern_data.cpp +++ b/wxdata/source/scwx/wsr88d/rda/volume_coverage_pattern_data.cpp @@ -1,6 +1,5 @@ #include - -#include +#include namespace scwx { @@ -10,7 +9,8 @@ namespace rda { static const std::string logPrefix_ = - "[scwx::wsr88d::rda::volume_coverage_pattern_data] "; + "scwx::wsr88d::rda::volume_coverage_pattern_data"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct Sector; @@ -137,8 +137,12 @@ float VolumeCoveragePatternData::doppler_velocity_resolution() const switch (p->dopplerVelocityResolution_) { - case 2: resolution = 0.5f; break; - case 4: resolution = 1.0f; break; + case 2: + resolution = 0.5f; + break; + case 4: + resolution = 1.0f; + break; } return resolution; @@ -233,12 +237,18 @@ WaveformType VolumeCoveragePatternData::waveform_type(uint16_t e) const { switch (p->elevationCuts_[e].waveformType_) { - case 1: return WaveformType::ContiguousSurveillance; - case 2: return WaveformType::ContiguousDopplerWithAmbiguityResolution; - case 3: return WaveformType::ContiguousDopplerWithoutAmbiguityResolution; - case 4: return WaveformType::Batch; - case 5: return WaveformType::StaggeredPulsePair; - default: return WaveformType::Unknown; + case 1: + return WaveformType::ContiguousSurveillance; + case 2: + return WaveformType::ContiguousDopplerWithAmbiguityResolution; + case 3: + return WaveformType::ContiguousDopplerWithoutAmbiguityResolution; + case 4: + return WaveformType::Batch; + case 5: + return WaveformType::StaggeredPulsePair; + default: + return WaveformType::Unknown; } } @@ -380,8 +390,7 @@ VolumeCoveragePatternData::doppler_prf_pulse_count_radial(uint16_t e, bool VolumeCoveragePatternData::Parse(std::istream& is) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Parsing Volume Coverage Pattern Data (Message Type 5)"; + logger_->trace("Parsing Volume Coverage Pattern Data (Message Type 5)"); bool messageValid = true; size_t bytesRead = 0; @@ -412,15 +421,13 @@ bool VolumeCoveragePatternData::Parse(std::istream& is) if (messageSize < 34 || messageSize > 747) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid message size: " << messageSize; + logger_->warn("Invalid message size: {}", messageSize); messageValid = false; } if (numberOfElevationCuts < 1 || numberOfElevationCuts > 32) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of elevation cuts: " << numberOfElevationCuts; + logger_->warn("Invalid number of elevation cuts: {}", + numberOfElevationCuts); messageValid = false; } @@ -483,9 +490,9 @@ bool VolumeCoveragePatternData::Parse(std::istream& is) if (messageValid && bytesRead != messageSize * 2) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Bytes read (" << bytesRead - << ") not equal to message size (" << messageSize * 2 << ")"; + logger_->warn("Bytes read ({}) not equal to message size ({})", + bytesRead, + messageSize * 2); } if (!ValidateMessage(is, bytesRead)) From 766940e60f5ccbf7327f8862c3f60c0566482593 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 17 Apr 2022 09:15:54 -0500 Subject: [PATCH 05/13] Boost.Log -> spdlog - wsr88d/rpg --- wxdata/source/scwx/wsr88d/rpg/ccb_header.cpp | 8 ++-- .../wsr88d/rpg/cell_trend_data_packet.cpp | 14 +++---- .../rpg/cell_trend_volume_scan_times.cpp | 14 +++---- ...igital_precipitation_data_array_packet.cpp | 21 ++++------ .../rpg/digital_radial_data_array_packet.cpp | 41 ++++++++----------- .../wsr88d/rpg/general_status_message.cpp | 4 +- .../scwx/wsr88d/rpg/generic_data_packet.cpp | 12 +++--- .../wsr88d/rpg/generic_radial_data_packet.cpp | 4 +- .../wsr88d/rpg/graphic_alphanumeric_block.cpp | 41 ++++++++----------- .../wsr88d/rpg/graphic_product_message.cpp | 23 ++++------- .../wsr88d/rpg/hda_hail_symbol_packet.cpp | 9 ++-- .../source/scwx/wsr88d/rpg/level3_message.cpp | 4 +- .../wsr88d/rpg/level3_message_factory.cpp | 11 +++-- .../scwx/wsr88d/rpg/level3_message_header.cpp | 32 ++++++--------- .../rpg/linked_contour_vector_packet.cpp | 16 ++++---- .../scwx/wsr88d/rpg/linked_vector_packet.cpp | 12 +++--- .../wsr88d/rpg/mesocyclone_symbol_packet.cpp | 9 ++-- wxdata/source/scwx/wsr88d/rpg/packet.cpp | 2 +- .../source/scwx/wsr88d/rpg/packet_factory.cpp | 14 +++---- .../rpg/point_feature_symbol_packet.cpp | 9 ++-- .../rpg/point_graphic_symbol_packet.cpp | 9 ++-- .../precipitation_rate_data_array_packet.cpp | 21 ++++------ .../wsr88d/rpg/product_description_block.cpp | 17 ++++---- .../wsr88d/rpg/product_symbology_block.cpp | 36 +++++++--------- .../scwx/wsr88d/rpg/radar_coded_message.cpp | 9 ++-- .../scwx/wsr88d/rpg/radial_data_packet.cpp | 27 +++++------- .../scwx/wsr88d/rpg/raster_data_packet.cpp | 22 ++++------ .../wsr88d/rpg/scit_forecast_data_packet.cpp | 9 ++-- .../wsr88d/rpg/set_color_level_packet.cpp | 16 ++++---- .../rpg/special_graphic_symbol_packet.cpp | 14 +++---- .../wsr88d/rpg/sti_circle_symbol_packet.cpp | 9 ++-- .../wsr88d/rpg/storm_id_symbol_packet.cpp | 9 ++-- .../wsr88d/rpg/tabular_alphanumeric_block.cpp | 34 ++++++--------- .../wsr88d/rpg/tabular_product_message.cpp | 11 +++-- .../rpg/text_and_special_symbol_packet.cpp | 17 ++++---- .../rpg/unlinked_contour_vector_packet.cpp | 11 +++-- .../wsr88d/rpg/unlinked_vector_packet.cpp | 11 +++-- .../wsr88d/rpg/vector_arrow_data_packet.cpp | 11 +++-- .../scwx/wsr88d/rpg/wind_barb_data_packet.cpp | 11 +++-- 39 files changed, 253 insertions(+), 351 deletions(-) diff --git a/wxdata/source/scwx/wsr88d/rpg/ccb_header.cpp b/wxdata/source/scwx/wsr88d/rpg/ccb_header.cpp index 92983a94..bfccc1cc 100644 --- a/wxdata/source/scwx/wsr88d/rpg/ccb_header.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/ccb_header.cpp @@ -1,12 +1,11 @@ #include +#include #include #include #include #include -#include - #ifdef WIN32 # include #else @@ -20,7 +19,8 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = "[scwx::wsr88d::rpg::ccb_header] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::ccb_header"; +static const auto logger_ = util::Logger::Create(logPrefix_); class CcbHeaderImpl { @@ -197,7 +197,7 @@ bool CcbHeader::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); headerValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/cell_trend_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/cell_trend_data_packet.cpp index e3c5ad19..36aecc65 100644 --- a/wxdata/source/scwx/wsr88d/rpg/cell_trend_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/cell_trend_data_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::cell_trend_data_packet] "; + "scwx::wsr88d::rpg::cell_trend_data_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct CellTrendData { @@ -134,21 +134,19 @@ bool CellTrendDataPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 21) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } else if (p->lengthOfBlock_ < 12 || p->lengthOfBlock_ > 198) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid length of block: " << p->packetCode_; + logger_->warn("Invalid length of block: {}", p->packetCode_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/cell_trend_volume_scan_times.cpp b/wxdata/source/scwx/wsr88d/rpg/cell_trend_volume_scan_times.cpp index 811e62ee..3fc87bc2 100644 --- a/wxdata/source/scwx/wsr88d/rpg/cell_trend_volume_scan_times.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/cell_trend_volume_scan_times.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::cell_trend_volume_scan_times] "; + "scwx::wsr88d::rpg::cell_trend_volume_scan_times"; +static const auto logger_ = util::Logger::Create(logPrefix_); class CellTrendVolumeScanTimesImpl { @@ -93,21 +93,19 @@ bool CellTrendVolumeScanTimes::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 22) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } else if (p->lengthOfBlock_ < 4 || p->lengthOfBlock_ > 22) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid length of block: " << p->packetCode_; + logger_->warn("Invalid length of block: {}", p->packetCode_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/digital_precipitation_data_array_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/digital_precipitation_data_array_packet.cpp index 6b8abb8b..10aa2688 100644 --- a/wxdata/source/scwx/wsr88d/rpg/digital_precipitation_data_array_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/digital_precipitation_data_array_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::digital_precipitation_data_array_packet] "; + "scwx::wsr88d::rpg::digital_precipitation_data_array_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class DigitalPrecipitationDataArrayPacketImpl { @@ -97,21 +97,19 @@ bool DigitalPrecipitationDataArrayPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 17) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } if (p->numberOfRows_ != 131) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of rows: " << p->numberOfRows_; + logger_->warn("Invalid number of rows: {}", p->numberOfRows_); blockValid = false; } } @@ -134,10 +132,9 @@ bool DigitalPrecipitationDataArrayPacket::Parse(std::istream& is) if (row.numberOfBytes_ < 2 || row.numberOfBytes_ > 262 || row.numberOfBytes_ % 2 != 0) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of bytes in row: " << row.numberOfBytes_ - << " (Row " << r << ")"; + logger_->warn("Invalid number of bytes in row: {} (Row {})", + row.numberOfBytes_, + r); blockValid = false; break; } diff --git a/wxdata/source/scwx/wsr88d/rpg/digital_radial_data_array_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/digital_radial_data_array_packet.cpp index f7bf3600..359c8947 100644 --- a/wxdata/source/scwx/wsr88d/rpg/digital_radial_data_array_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/digital_radial_data_array_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::digital_radial_data_array_packet] "; + "scwx::wsr88d::rpg::digital_radial_data_array_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class DigitalRadialDataArrayPacketImpl { @@ -148,36 +148,31 @@ bool DigitalRadialDataArrayPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 16) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } if (p->indexOfFirstRangeBin_ < 0 || p->indexOfFirstRangeBin_ > 230) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid index of first range bin: " << p->indexOfFirstRangeBin_; + logger_->warn("Invalid index of first range bin: {}", + p->indexOfFirstRangeBin_); blockValid = false; } if (p->numberOfRangeBins_ < 0 || p->numberOfRangeBins_ > 1840) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of range bins: " << p->numberOfRangeBins_; + logger_->warn("Invalid number of range bins: {}", + p->numberOfRangeBins_); blockValid = false; } if (p->numberOfRadials_ < 1 || p->numberOfRadials_ > 720) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of radials: " << p->numberOfRadials_; + logger_->warn("Invalid number of radials: {}", p->numberOfRadials_); blockValid = false; } } @@ -201,19 +196,19 @@ bool DigitalRadialDataArrayPacket::Parse(std::istream& is) if (radial.numberOfBytes_ < 1 || radial.numberOfBytes_ > 1840) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of bytes: " << radial.numberOfBytes_ - << " (Radial " << r << ")"; + logger_->warn("Invalid number of bytes: {} (Radial {})", + radial.numberOfBytes_, + r); blockValid = false; break; } else if (radial.numberOfBytes_ < p->numberOfRangeBins_) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Number of bytes < number of range bins: " - << radial.numberOfBytes_ << " < " << p->numberOfRangeBins_ - << " (Radial " << r << ")"; + logger_->warn( + "Number of bytes < number of range bins: {} < {} (Radial {})", + radial.numberOfBytes_, + p->numberOfRangeBins_, + r); blockValid = false; break; } diff --git a/wxdata/source/scwx/wsr88d/rpg/general_status_message.cpp b/wxdata/source/scwx/wsr88d/rpg/general_status_message.cpp index bdc7b869..4d362487 100644 --- a/wxdata/source/scwx/wsr88d/rpg/general_status_message.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/general_status_message.cpp @@ -4,8 +4,6 @@ #include #include -#include - namespace scwx { namespace wsr88d @@ -14,7 +12,7 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::general_status_message] "; + "scwx::wsr88d::rpg::general_status_message"; class GeneralStatusMessageImpl { diff --git a/wxdata/source/scwx/wsr88d/rpg/generic_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/generic_data_packet.cpp index 322b56ae..af5cc67e 100644 --- a/wxdata/source/scwx/wsr88d/rpg/generic_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/generic_data_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -12,8 +11,8 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::generic_data_packet] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::generic_data_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class GenericDataPacketImpl { @@ -70,15 +69,14 @@ bool GenericDataPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 28 && p->packetCode_ != 29) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/generic_radial_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/generic_radial_data_packet.cpp index 51ed5db7..e409d24e 100644 --- a/wxdata/source/scwx/wsr88d/rpg/generic_radial_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/generic_radial_data_packet.cpp @@ -2,8 +2,6 @@ #include -#include - namespace scwx { namespace wsr88d @@ -12,7 +10,7 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::generic_radial_data_packet] "; + "scwx::wsr88d::rpg::generic_radial_data_packet"; class GenericRadialDataPacketImpl { diff --git a/wxdata/source/scwx/wsr88d/rpg/graphic_alphanumeric_block.cpp b/wxdata/source/scwx/wsr88d/rpg/graphic_alphanumeric_block.cpp index 8786efee..a5cc2b3a 100644 --- a/wxdata/source/scwx/wsr88d/rpg/graphic_alphanumeric_block.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/graphic_alphanumeric_block.cpp @@ -1,11 +1,10 @@ #include #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -14,7 +13,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::graphic_alphanumeric_block] "; + "scwx::wsr88d::rpg::graphic_alphanumeric_block"; +static const auto logger_ = util::Logger::Create(logPrefix_); class GraphicAlphanumericBlockImpl { @@ -76,33 +76,29 @@ bool GraphicAlphanumericBlock::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->blockDivider_ != -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block divider: " << p->blockDivider_; + logger_->warn("Invalid block divider: {}", p->blockDivider_); blockValid = false; } if (p->blockId_ != 2) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block ID: " << p->blockId_; + logger_->warn("Invalid block ID: {}", p->blockId_); blockValid = false; } if (p->lengthOfBlock_ < 10) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block length: " << p->lengthOfBlock_; + logger_->warn("Invalid block length: {}", p->lengthOfBlock_); blockValid = false; } if (p->numberOfPages_ < 1 || p->numberOfPages_ > 48) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of pages: " << p->numberOfPages_; + logger_->warn("Invalid number of pages: {}", p->numberOfPages_); blockValid = false; } } @@ -114,7 +110,7 @@ bool GraphicAlphanumericBlock::Parse(std::istream& is) for (uint16_t i = 0; i < p->numberOfPages_; i++) { - BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Page " << (i + 1); + logger_->trace("Page {}", (i + 1)); std::vector> packetList; uint32_t bytesRead = 0; @@ -131,9 +127,8 @@ bool GraphicAlphanumericBlock::Parse(std::istream& is) if (pageNumber != i + 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Page out of order: Expected " << (i + 1) - << ", found " << pageNumber; + logger_->warn( + "Page out of order: Expected {}, found {}", (i + 1), pageNumber); } while (bytesRead < lengthOfPage) @@ -152,19 +147,17 @@ bool GraphicAlphanumericBlock::Parse(std::istream& is) if (bytesRead < lengthOfPage) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ - << "Page bytes read smaller than size: " << bytesRead << " < " - << lengthOfPage << " bytes"; + logger_->trace("Page bytes read smaller than size: {} < {} bytes", + bytesRead, + lengthOfPage); blockValid = false; is.seekg(pageEnd, std::ios_base::beg); } if (bytesRead > lengthOfPage) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Page bytes read larger than size: " << bytesRead << " > " - << lengthOfPage << " bytes"; + logger_->warn("Page bytes read larger than size: {} > {} bytes", + bytesRead, + lengthOfPage); blockValid = false; is.seekg(pageEnd, std::ios_base::beg); } diff --git a/wxdata/source/scwx/wsr88d/rpg/graphic_product_message.cpp b/wxdata/source/scwx/wsr88d/rpg/graphic_product_message.cpp index 6f2b99f7..b41d7aeb 100644 --- a/wxdata/source/scwx/wsr88d/rpg/graphic_product_message.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/graphic_product_message.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -7,7 +8,6 @@ #include #include #include -#include namespace scwx { @@ -17,7 +17,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::graphic_product_message] "; + "scwx::wsr88d::rpg::graphic_product_message"; +static const auto logger_ = util::Logger::Create(logPrefix_); class GraphicProductMessageImpl { @@ -102,17 +103,14 @@ bool GraphicProductMessage::Parse(std::istream& is) { std::stringstream ss; std::streamsize bytesCopied = boost::iostreams::copy(in, ss); - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Decompressed data size = " << bytesCopied - << " bytes"; + logger_->trace("Decompressed data size = {} bytes", bytesCopied); dataValid = p->LoadBlocks(ss); } catch (const boost::iostreams::bzip2_error& ex) { int error = ex.error(); - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Error decompressing data: " << ex.what(); + logger_->warn("Error decompressing data: {}", ex.what()); dataValid = false; } @@ -138,7 +136,7 @@ bool GraphicProductMessageImpl::LoadBlocks(std::istream& is) bool graphicValid = true; bool tabularValid = true; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Blocks"; + logger_->debug("Loading Blocks"); std::streampos offsetBasePos = is.tellg(); @@ -157,8 +155,7 @@ bool GraphicProductMessageImpl::LoadBlocks(std::istream& is) symbologyValid = symbologyBlock_->Parse(is); is.seekg(offsetBasePos, std::ios_base::beg); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Product symbology block valid: " << symbologyValid; + logger_->debug("Product symbology block valid: {}", symbologyValid); if (!symbologyValid) { @@ -174,8 +171,7 @@ bool GraphicProductMessageImpl::LoadBlocks(std::istream& is) graphicValid = graphicBlock_->Parse(is); is.seekg(offsetBasePos, std::ios_base::beg); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Graphic alphanumeric block valid: " << graphicValid; + logger_->debug("Graphic alphanumeric block valid: {}", graphicValid); if (!graphicValid) { @@ -191,8 +187,7 @@ bool GraphicProductMessageImpl::LoadBlocks(std::istream& is) tabularValid = tabularBlock_->Parse(is); is.seekg(offsetBasePos, std::ios_base::beg); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Tabular alphanumeric block valid: " << tabularValid; + logger_->debug("Tabular alphanumeric block valid: {}", tabularValid); if (!tabularValid) { diff --git a/wxdata/source/scwx/wsr88d/rpg/hda_hail_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/hda_hail_symbol_packet.cpp index 07ccd0b0..9c6f893b 100644 --- a/wxdata/source/scwx/wsr88d/rpg/hda_hail_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/hda_hail_symbol_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::hda_hail_symbol_packet] "; + "scwx::wsr88d::rpg::hda_hail_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct HdaHailSymbol { @@ -90,8 +90,7 @@ bool HdaHailSymbolPacket::ParseData(std::istream& is) if (packet_code() != 19) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << packet_code(); + logger_->warn("Invalid packet code: {}", packet_code()); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/level3_message.cpp b/wxdata/source/scwx/wsr88d/rpg/level3_message.cpp index 90944304..cd628f03 100644 --- a/wxdata/source/scwx/wsr88d/rpg/level3_message.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/level3_message.cpp @@ -1,7 +1,5 @@ #include -#include - namespace scwx { namespace wsr88d @@ -9,7 +7,7 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = "[scwx::wsr88d::rpg::level3_message] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::level3_message"; class Level3MessageImpl { diff --git a/wxdata/source/scwx/wsr88d/rpg/level3_message_factory.cpp b/wxdata/source/scwx/wsr88d/rpg/level3_message_factory.cpp index 505a2b0a..66665327 100644 --- a/wxdata/source/scwx/wsr88d/rpg/level3_message_factory.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/level3_message_factory.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -9,8 +10,6 @@ #include #include -#include - namespace scwx { namespace wsr88d @@ -19,7 +18,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::level3_message_factory] "; + "scwx::wsr88d::rpg::level3_message_factory"; +static const auto logger_ = util::Logger::Create(logPrefix_); typedef std::function(Level3MessageHeader&&, std::istream&)> @@ -133,8 +133,7 @@ std::shared_ptr Level3MessageFactory::Create(std::istream& is) if (headerValid && create_.find(header.message_code()) == create_.end()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Unknown message type: " << header.message_code(); + logger_->warn("Unknown message type: {}", header.message_code()); messageValid = false; } @@ -143,7 +142,7 @@ std::shared_ptr Level3MessageFactory::Create(std::istream& is) int16_t messageCode = header.message_code(); size_t dataSize = header.length_of_message() - Level3MessageHeader::SIZE; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Found Message " << messageCode; + logger_->debug("Found Message {}", messageCode); message = create_.at(messageCode)(std::move(header), is); } diff --git a/wxdata/source/scwx/wsr88d/rpg/level3_message_header.cpp b/wxdata/source/scwx/wsr88d/rpg/level3_message_header.cpp index e5c5866f..7ad5c168 100644 --- a/wxdata/source/scwx/wsr88d/rpg/level3_message_header.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/level3_message_header.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - #ifdef WIN32 # include #else @@ -19,7 +18,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::level3_message_header] "; + "scwx::wsr88d::rpg::level3_message_header"; +static const auto logger_ = util::Logger::Create(logPrefix_); class Level3MessageHeaderImpl { @@ -113,7 +113,7 @@ bool Level3MessageHeader::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); headerValid = false; } else @@ -122,52 +122,44 @@ bool Level3MessageHeader::Parse(std::istream& is) (p->messageCode_ > -16 && p->messageCode_ < 0) || p->messageCode_ > 211) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid message code: " << p->messageCode_; + logger_->warn("Invalid message code: {}", p->messageCode_); headerValid = false; } if (p->dateOfMessage_ > 32'767u) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid date: " << p->dateOfMessage_; + logger_->warn("Invalid date: {}", p->dateOfMessage_); headerValid = false; } if (p->timeOfMessage_ > 86'399u) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid time: " << p->timeOfMessage_; + logger_->warn("Invalid time: {}", p->timeOfMessage_); headerValid = false; } if (p->lengthOfMessage_ < 18 || p->lengthOfMessage_ > 1'329'270u) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid length: " << p->lengthOfMessage_; + logger_->warn("Invalid length: {}", p->lengthOfMessage_); headerValid = false; } if ((p->sourceId_ > 999u && p->sourceId_ < 3000) || p->sourceId_ > 3045) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid source ID: " << p->sourceId_; + logger_->warn("Invalid source ID: {}", p->sourceId_); headerValid = false; } if (p->destinationId_ > 999u) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid destination ID: " << p->destinationId_; + logger_->warn("Invalid destination ID: {}", p->destinationId_); headerValid = false; } if (p->numberBlocks_ < 1u || p->numberBlocks_ > 51u) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block count: " << p->numberBlocks_; + logger_->warn("Invalid block count: {}", p->numberBlocks_); headerValid = false; } } if (headerValid) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Message code: " << p->messageCode_; + logger_->trace("Message code: {}", p->messageCode_); } return headerValid; diff --git a/wxdata/source/scwx/wsr88d/rpg/linked_contour_vector_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/linked_contour_vector_packet.cpp index cfc1714c..868f03c5 100644 --- a/wxdata/source/scwx/wsr88d/rpg/linked_contour_vector_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/linked_contour_vector_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::linked_contour_vector_packet] "; + "scwx::wsr88d::rpg::linked_contour_vector_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class LinkedContourVectorPacketImpl { @@ -93,22 +93,20 @@ bool LinkedContourVectorPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 0x0E03) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } if (p->initialPointIndicator_ != 0x8000) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid initial point indicator: " << p->initialPointIndicator_; + logger_->warn("Invalid initial point indicator: {}", + p->initialPointIndicator_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/linked_vector_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/linked_vector_packet.cpp index 26b81047..f12c35dd 100644 --- a/wxdata/source/scwx/wsr88d/rpg/linked_vector_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/linked_vector_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -12,8 +11,8 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::linked_vector_packet] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::linked_vector_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class LinkedVectorPacketImpl { @@ -93,7 +92,7 @@ bool LinkedVectorPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else if (p->packetCode_ == 9) @@ -107,8 +106,7 @@ bool LinkedVectorPacket::Parse(std::istream& is) { if (p->packetCode_ != 6 && p->packetCode_ != 9) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/mesocyclone_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/mesocyclone_symbol_packet.cpp index c6a97f3e..cd6f4989 100644 --- a/wxdata/source/scwx/wsr88d/rpg/mesocyclone_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/mesocyclone_symbol_packet.cpp @@ -1,11 +1,10 @@ #include +#include #include #include #include -#include - namespace scwx { namespace wsr88d @@ -14,7 +13,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::mesocyclone_symbol_packet] "; + "scwx::wsr88d::rpg::mesocyclone_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); static const std::set packetCodes_ = {3, 11}; @@ -77,8 +77,7 @@ bool MesocycloneSymbolPacket::ParseData(std::istream& is) if (!packetCodes_.contains(packet_code())) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << packet_code(); + logger_->warn("Invalid packet code: {}", packet_code()); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/packet.cpp b/wxdata/source/scwx/wsr88d/rpg/packet.cpp index aeb5b846..5e980a2e 100644 --- a/wxdata/source/scwx/wsr88d/rpg/packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/packet.cpp @@ -7,7 +7,7 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = "[scwx::wsr88d::rpg::packet] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::packet"; Packet::Packet() = default; Packet::~Packet() = default; diff --git a/wxdata/source/scwx/wsr88d/rpg/packet_factory.cpp b/wxdata/source/scwx/wsr88d/rpg/packet_factory.cpp index 8641aa81..def24f5d 100644 --- a/wxdata/source/scwx/wsr88d/rpg/packet_factory.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/packet_factory.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -26,8 +27,6 @@ #include -#include - namespace scwx { namespace wsr88d @@ -35,7 +34,8 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = "[scwx::wsr88d::rpg::packet_factory] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::packet_factory"; +static const auto logger_ = util::Logger::Create(logPrefix_); typedef std::function(std::istream&)> CreateMessageFunction; @@ -95,17 +95,13 @@ std::shared_ptr PacketFactory::Create(std::istream& is) if (packetValid && create_.find(packetCode) == create_.end()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Unknown packet code: " << packetCode << " (0x" - << std::hex << packetCode << std::dec << ")"; + logger_->warn("Unknown packet code: {0} (0x{0:x})", packetCode); packetValid = false; } if (packetValid) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Found packet code: " << packetCode << " (0x" - << std::hex << packetCode << std::dec << ")"; + logger_->trace("Found packet code: {0} (0x{0:x})", packetCode); packet = create_.at(packetCode)(is); } diff --git a/wxdata/source/scwx/wsr88d/rpg/point_feature_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/point_feature_symbol_packet.cpp index 14e4907a..4bcc5a55 100644 --- a/wxdata/source/scwx/wsr88d/rpg/point_feature_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/point_feature_symbol_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::point_feature_symbol_packet] "; + "scwx::wsr88d::rpg::point_feature_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct PointFeature { @@ -95,8 +95,7 @@ bool PointFeatureSymbolPacket::ParseData(std::istream& is) if (packet_code() != 20) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << packet_code(); + logger_->warn("Invalid packet code: {}", packet_code()); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/point_graphic_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/point_graphic_symbol_packet.cpp index 1266d5a0..df63153d 100644 --- a/wxdata/source/scwx/wsr88d/rpg/point_graphic_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/point_graphic_symbol_packet.cpp @@ -1,11 +1,10 @@ #include +#include #include #include #include -#include - namespace scwx { namespace wsr88d @@ -14,7 +13,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::point_graphic_symbol_packet] "; + "scwx::wsr88d::rpg::point_graphic_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); static const std::set packetCodes_ = {12, 13, 14, 26}; @@ -70,8 +70,7 @@ bool PointGraphicSymbolPacket::ParseData(std::istream& is) if (!packetCodes_.contains(packet_code())) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << packet_code(); + logger_->warn("Invalid packet code: {}", packet_code()); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.cpp index 6d405195..03dbc722 100644 --- a/wxdata/source/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::precipitation_rate_data_array_packet] "; + "scwx::wsr88d::rpg::precipitation_rate_data_array_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class PrecipitationRateDataArrayPacketImpl { @@ -94,21 +94,19 @@ bool PrecipitationRateDataArrayPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 18) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } if (p->numberOfRows_ != 13) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of rows: " << p->numberOfRows_; + logger_->warn("Invalid number of rows: {}", p->numberOfRows_); blockValid = false; } } @@ -131,10 +129,9 @@ bool PrecipitationRateDataArrayPacket::Parse(std::istream& is) if (row.numberOfBytes_ < 2 || row.numberOfBytes_ > 14 || row.numberOfBytes_ % 2 != 0) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of bytes in row: " << row.numberOfBytes_ - << " (Row " << r << ")"; + logger_->warn("Invalid number of bytes in row: {} (Row {})", + row.numberOfBytes_, + r); blockValid = false; break; } diff --git a/wxdata/source/scwx/wsr88d/rpg/product_description_block.cpp b/wxdata/source/scwx/wsr88d/rpg/product_description_block.cpp index 23fb01ed..38b17372 100644 --- a/wxdata/source/scwx/wsr88d/rpg/product_description_block.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/product_description_block.cpp @@ -1,13 +1,12 @@ #include #include +#include #include #include #include #include -#include - namespace scwx { namespace wsr88d @@ -16,7 +15,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::product_description_block] "; + "scwx::wsr88d::rpg::product_description_block"; +static const auto logger_ = util::Logger::Create(logPrefix_); static const std::set compressedProducts_ = { 32, 94, 99, 134, 135, 138, 149, 152, 153, 154, 155, @@ -660,31 +660,28 @@ bool ProductDescriptionBlock::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->blockDivider_ != -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block divider: " << p->blockDivider_; + logger_->warn("Invalid block divider: {}", p->blockDivider_); blockValid = false; } if (p->productCode_ < -299 || (p->productCode_ > -16 && p->productCode_ < 16) || p->productCode_ > 299) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid product code: " << p->productCode_; + logger_->warn("Invalid product code: {}", p->productCode_); blockValid = false; } } if (blockValid) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Product code: " << p->productCode_; + logger_->trace("Product code: {}", p->productCode_); } const std::streampos blockEnd = is.tellg(); diff --git a/wxdata/source/scwx/wsr88d/rpg/product_symbology_block.cpp b/wxdata/source/scwx/wsr88d/rpg/product_symbology_block.cpp index 9c808dbc..b4121b51 100644 --- a/wxdata/source/scwx/wsr88d/rpg/product_symbology_block.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/product_symbology_block.cpp @@ -1,11 +1,10 @@ #include #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -14,7 +13,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::product_symbology_block] "; + "scwx::wsr88d::rpg::product_symbology_block"; +static const auto logger_ = util::Logger::Create(logPrefix_); class ProductSymbologyBlockImpl { @@ -87,33 +87,29 @@ bool ProductSymbologyBlock::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->blockDivider_ != -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block divider: " << p->blockDivider_; + logger_->warn("Invalid block divider: {}", p->blockDivider_); blockValid = false; } if (p->blockId_ != 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block ID: " << p->blockId_; + logger_->warn("Invalid block ID: {}", p->blockId_); blockValid = false; } if (p->lengthOfBlock_ < 10) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block length: " << p->lengthOfBlock_; + logger_->warn("Invalid block length: {}", p->lengthOfBlock_); blockValid = false; } if (p->numberOfLayers_ < 1 || p->numberOfLayers_ > 18) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of layers: " << p->numberOfLayers_; + logger_->warn("Invalid number of layers: {}", p->numberOfLayers_); blockValid = false; } } @@ -125,7 +121,7 @@ bool ProductSymbologyBlock::Parse(std::istream& is) for (uint16_t i = 0; i < p->numberOfLayers_; i++) { - BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Layer " << i; + logger_->trace("Layer {}", i); std::vector> packetList; uint32_t bytesRead = 0; @@ -156,19 +152,17 @@ bool ProductSymbologyBlock::Parse(std::istream& is) if (bytesRead < lengthOfDataLayer) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ - << "Layer bytes read smaller than size: " << bytesRead << " < " - << lengthOfDataLayer << " bytes"; + logger_->trace("Layer bytes read smaller than size: {} < {} bytes", + bytesRead, + lengthOfDataLayer); blockValid = false; is.seekg(layerEnd, std::ios_base::beg); } if (bytesRead > lengthOfDataLayer) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Layer bytes read larger than size: " << bytesRead << " > " - << lengthOfDataLayer << " bytes"; + logger_->warn("Layer bytes read larger than size: {} > {} bytes", + bytesRead, + lengthOfDataLayer); blockValid = false; is.seekg(layerEnd, std::ios_base::beg); } diff --git a/wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp b/wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp index 7bb11c0c..ebe79655 100644 --- a/wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -12,8 +11,8 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::radar_coded_message] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::radar_coded_message"; +static const auto logger_ = util::Logger::Create(logPrefix_); class RadarCodedMessageImpl { @@ -77,7 +76,7 @@ bool RadarCodedMessage::Parse(std::istream& is) bool RadarCodedMessageImpl::LoadBlocks(std::istream& is) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Blocks"; + logger_->debug("Loading Blocks"); pupSiteIdentifier_.resize(4); productCategory_.resize(5); diff --git a/wxdata/source/scwx/wsr88d/rpg/radial_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/radial_data_packet.cpp index fd4e8b0e..3e530683 100644 --- a/wxdata/source/scwx/wsr88d/rpg/radial_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/radial_data_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -12,8 +11,8 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::radial_data_packet] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::radial_data_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class RadialDataPacketImpl { @@ -152,29 +151,25 @@ bool RadialDataPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 0xAF1F) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } if (p->numberOfRangeBins_ < 1 || p->numberOfRangeBins_ > 460) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of range bins: " << p->numberOfRangeBins_; + logger_->warn("Invalid number of range bins: {}", + p->numberOfRangeBins_); blockValid = false; } if (p->numberOfRadials_ < 1 || p->numberOfRadials_ > 400) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of radials: " << p->numberOfRadials_; + logger_->warn("Invalid number of radials: {}", p->numberOfRadials_); blockValid = false; } } @@ -199,9 +194,9 @@ bool RadialDataPacket::Parse(std::istream& is) if (radial.numberOfRleHalfwords_ < 1 || radial.numberOfRleHalfwords_ > 230) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of RLE halfwords: " - << radial.numberOfRleHalfwords_ << " (Radial " << r << ")"; + logger_->warn("Invalid number of RLE halfwords: {} (Radial {})", + radial.numberOfRleHalfwords_, + r); blockValid = false; break; } diff --git a/wxdata/source/scwx/wsr88d/rpg/raster_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/raster_data_packet.cpp index 3915ed7b..5741e5a6 100644 --- a/wxdata/source/scwx/wsr88d/rpg/raster_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/raster_data_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -12,8 +11,8 @@ namespace wsr88d namespace rpg { -static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::raster_data_packet] "; +static const std::string logPrefix_ = "scwx::wsr88d::rpg::raster_data_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class RasterDataPacketImpl { @@ -162,21 +161,19 @@ bool RasterDataPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 0xBA0F && p->packetCode_ != 0xBA07) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } if (p->numberOfRows_ < 1 || p->numberOfRows_ > 464) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of rows: " << p->numberOfRows_; + logger_->warn("Invalid number of rows: {}", p->numberOfRows_); blockValid = false; } } @@ -199,10 +196,9 @@ bool RasterDataPacket::Parse(std::istream& is) if (row.numberOfBytes_ < 2 || row.numberOfBytes_ > 920 || row.numberOfBytes_ % 2 != 0) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of bytes in row: " << row.numberOfBytes_ - << " (Row " << r << ")"; + logger_->warn("Invalid number of bytes in row: {} (Row {})", + row.numberOfBytes_, + r); blockValid = false; break; } diff --git a/wxdata/source/scwx/wsr88d/rpg/scit_forecast_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/scit_forecast_data_packet.cpp index a0599920..86899bec 100644 --- a/wxdata/source/scwx/wsr88d/rpg/scit_forecast_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/scit_forecast_data_packet.cpp @@ -1,11 +1,10 @@ #include +#include #include #include #include -#include - namespace scwx { namespace wsr88d @@ -14,7 +13,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::scit_forecast_data_packet] "; + "scwx::wsr88d::rpg::scit_forecast_data_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); static const std::set packetCodes_ = {23, 24}; @@ -55,8 +55,7 @@ bool ScitForecastDataPacket::ParseData(std::istream& is) if (!packetCodes_.contains(packet_code())) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << packet_code(); + logger_->warn("Invalid packet code: {}", packet_code()); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/set_color_level_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/set_color_level_packet.cpp index 2382a0e5..3531ce6f 100644 --- a/wxdata/source/scwx/wsr88d/rpg/set_color_level_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/set_color_level_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::set_color_level_packet] "; + "scwx::wsr88d::rpg::set_color_level_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class SetColorLevelPacketImpl { @@ -76,22 +76,20 @@ bool SetColorLevelPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 0x0802) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } if (p->colorValueIndicator_ != 0x0002) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid color value indicator: " << p->colorValueIndicator_; + logger_->warn("Invalid color value indicator: {}", + p->colorValueIndicator_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/special_graphic_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/special_graphic_symbol_packet.cpp index cca2bc9b..c02aba02 100644 --- a/wxdata/source/scwx/wsr88d/rpg/special_graphic_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/special_graphic_symbol_packet.cpp @@ -1,11 +1,10 @@ #include +#include #include #include #include -#include - namespace scwx { namespace wsr88d @@ -14,7 +13,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::special_graphic_symbol_packet] "; + "scwx::wsr88d::rpg::special_graphic_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); static const std::set packetCodes_ = { 3, 11, 12, 13, 14, 15, 19, 20, 23, 24, 25, 26}; @@ -72,7 +72,7 @@ bool SpecialGraphicSymbolPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else @@ -82,15 +82,13 @@ bool SpecialGraphicSymbolPacket::Parse(std::istream& is) if (!packetCodes_.contains(p->packetCode_)) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } else if (p->lengthOfBlock_ < minBlockLength || p->lengthOfBlock_ > maxBlockLength) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid length of block: " << p->packetCode_; + logger_->warn("Invalid length of block: {}", p->lengthOfBlock_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/sti_circle_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/sti_circle_symbol_packet.cpp index 38145701..56173e76 100644 --- a/wxdata/source/scwx/wsr88d/rpg/sti_circle_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/sti_circle_symbol_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::sti_circle_symbol_packet] "; + "scwx::wsr88d::rpg::sti_circle_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct StiCircleSymbol { @@ -71,8 +71,7 @@ bool StiCircleSymbolPacket::ParseData(std::istream& is) if (packet_code() != 25) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << packet_code(); + logger_->warn("Invalid packet code: {}", packet_code()); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/storm_id_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/storm_id_symbol_packet.cpp index c95b6125..ada7c588 100644 --- a/wxdata/source/scwx/wsr88d/rpg/storm_id_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/storm_id_symbol_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::storm_id_symbol_packet] "; + "scwx::wsr88d::rpg::storm_id_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct StormIdSymbol { @@ -71,8 +71,7 @@ bool StormIdSymbolPacket::ParseData(std::istream& is) if (packet_code() != 15) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << packet_code(); + logger_->warn("Invalid packet code: {}", packet_code()); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/tabular_alphanumeric_block.cpp b/wxdata/source/scwx/wsr88d/rpg/tabular_alphanumeric_block.cpp index 39db8119..0fa1185a 100644 --- a/wxdata/source/scwx/wsr88d/rpg/tabular_alphanumeric_block.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/tabular_alphanumeric_block.cpp @@ -2,12 +2,11 @@ #include #include #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -16,7 +15,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::tabular_alphanumeric_block] "; + "scwx::wsr88d::rpg::tabular_alphanumeric_block"; +static const auto logger_ = util::Logger::Create(logPrefix_); class TabularAlphanumericBlockImpl { @@ -92,28 +92,24 @@ bool TabularAlphanumericBlock::Parse(std::istream& is, bool skipHeader) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->blockDivider1_ != -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid first block divider: " << p->blockDivider1_; + logger_->warn("Invalid first block divider: {}", p->blockDivider1_); blockValid = false; } if (p->blockId_ != 3) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block ID: " << p->blockId_; + logger_->warn("Invalid block ID: {}", p->blockId_); blockValid = false; } if (p->lengthOfBlock_ < 10) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid block length: " << p->lengthOfBlock_; + logger_->warn("Invalid block length: {}", p->lengthOfBlock_); blockValid = false; } } @@ -151,15 +147,12 @@ bool TabularAlphanumericBlock::Parse(std::istream& is, bool skipHeader) if (p->blockDivider2_ != -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid second block divider: " << p->blockDivider2_; + logger_->warn("Invalid second block divider: {}", p->blockDivider2_); blockValid = false; } if (p->numberOfPages_ < 1 || p->numberOfPages_ > 48) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid number of pages: " << p->numberOfPages_; + logger_->warn("Invalid number of pages: {}", p->numberOfPages_); blockValid = false; } } @@ -184,10 +177,9 @@ bool TabularAlphanumericBlock::Parse(std::istream& is, bool skipHeader) } else if (numberOfCharacters > 80) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ - << "Invalid number of characters: " << numberOfCharacters - << " (Page " << (i + 1) << ")"; + logger_->warn("Invalid number of characters: {} (Page {})", + numberOfCharacters, + (i + 1)); blockValid = false; break; } @@ -211,7 +203,7 @@ bool TabularAlphanumericBlock::Parse(std::istream& is, bool skipHeader) } else if (skipHeader && is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/tabular_product_message.cpp b/wxdata/source/scwx/wsr88d/rpg/tabular_product_message.cpp index ca59e561..17193779 100644 --- a/wxdata/source/scwx/wsr88d/rpg/tabular_product_message.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/tabular_product_message.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::tabular_product_message] "; + "scwx::wsr88d::rpg::tabular_product_message"; +static const auto logger_ = util::Logger::Create(logPrefix_); class TabularProductMessageImpl { @@ -82,7 +82,7 @@ bool TabularProductMessageImpl::LoadBlocks(std::istream& is) bool tabularValid = true; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Blocks"; + logger_->debug("Loading Blocks"); std::streampos offsetBasePos = is.tellg(); @@ -99,8 +99,7 @@ bool TabularProductMessageImpl::LoadBlocks(std::istream& is) tabularValid = tabularBlock_->Parse(is, skipTabularHeader); is.seekg(offsetBasePos, std::ios_base::beg); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Tabular alphanumeric block valid: " << tabularValid; + logger_->debug("Tabular alphanumeric block valid: {}", tabularValid); if (!tabularValid) { diff --git a/wxdata/source/scwx/wsr88d/rpg/text_and_special_symbol_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/text_and_special_symbol_packet.cpp index 59e47de6..a0833717 100644 --- a/wxdata/source/scwx/wsr88d/rpg/text_and_special_symbol_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/text_and_special_symbol_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::text_and_special_symbol_packet] "; + "scwx::wsr88d::rpg::text_and_special_symbol_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class TextAndSpecialSymbolPacketImpl { @@ -113,21 +113,19 @@ bool TextAndSpecialSymbolPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 1 && p->packetCode_ != 2 && p->packetCode_ != 8) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } else if (p->lengthOfBlock_ < 1 || p->lengthOfBlock_ > 32767) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid length of block: " << p->packetCode_; + logger_->warn("Invalid length of block: {}", p->lengthOfBlock_); blockValid = false; } else if (p->packetCode_ == 8) @@ -141,8 +139,7 @@ bool TextAndSpecialSymbolPacket::Parse(std::istream& is) if (blockValid && textLength < 0) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Too few bytes in block: " << p->lengthOfBlock_; + logger_->warn("Too few bytes in block: {}", p->lengthOfBlock_); blockValid = false; } diff --git a/wxdata/source/scwx/wsr88d/rpg/unlinked_contour_vector_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/unlinked_contour_vector_packet.cpp index 6e86ee1c..9b9ff467 100644 --- a/wxdata/source/scwx/wsr88d/rpg/unlinked_contour_vector_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/unlinked_contour_vector_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::unlinked_contour_vector_packet] "; + "scwx::wsr88d::rpg::unlinked_contour_vector_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class UnlinkedContourVectorPacketImpl { @@ -80,15 +80,14 @@ bool UnlinkedContourVectorPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 0x3501) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/unlinked_vector_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/unlinked_vector_packet.cpp index 0cb9708b..d6984b8b 100644 --- a/wxdata/source/scwx/wsr88d/rpg/unlinked_vector_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/unlinked_vector_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::unlinked_vector_packet] "; + "scwx::wsr88d::rpg::unlinked_vector_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); class UnlinkedVectorPacketImpl { @@ -94,7 +94,7 @@ bool UnlinkedVectorPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else if (p->packetCode_ == 10) @@ -108,8 +108,7 @@ bool UnlinkedVectorPacket::Parse(std::istream& is) { if (p->packetCode_ != 7 && p->packetCode_ != 10) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/vector_arrow_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/vector_arrow_data_packet.cpp index 277a6660..06a15d39 100644 --- a/wxdata/source/scwx/wsr88d/rpg/vector_arrow_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/vector_arrow_data_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::vector_arrow_data_packet] "; + "scwx::wsr88d::rpg::vector_arrow_data_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct VectorArrow { @@ -88,15 +88,14 @@ bool VectorArrowDataPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 5) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } } diff --git a/wxdata/source/scwx/wsr88d/rpg/wind_barb_data_packet.cpp b/wxdata/source/scwx/wsr88d/rpg/wind_barb_data_packet.cpp index e593ae39..ae9fb2cc 100644 --- a/wxdata/source/scwx/wsr88d/rpg/wind_barb_data_packet.cpp +++ b/wxdata/source/scwx/wsr88d/rpg/wind_barb_data_packet.cpp @@ -1,10 +1,9 @@ #include +#include #include #include -#include - namespace scwx { namespace wsr88d @@ -13,7 +12,8 @@ namespace rpg { static const std::string logPrefix_ = - "[scwx::wsr88d::rpg::wind_barb_data_packet] "; + "scwx::wsr88d::rpg::wind_barb_data_packet"; +static const auto logger_ = util::Logger::Create(logPrefix_); struct WindBarb { @@ -87,15 +87,14 @@ bool WindBarbDataPacket::Parse(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; + logger_->debug("Reached end of file"); blockValid = false; } else { if (p->packetCode_ != 4) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid packet code: " << p->packetCode_; + logger_->warn("Invalid packet code: {}", p->packetCode_); blockValid = false; } } From 40ef43ed30963f15cb9eea4175cc8310d85a11e5 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 17 Apr 2022 09:28:17 -0500 Subject: [PATCH 06/13] Boost.Log -> spdlog - wsr88d --- wxdata/source/scwx/wsr88d/ar2v_file.cpp | 61 ++++++++----------- wxdata/source/scwx/wsr88d/level3_file.cpp | 38 +++++------- .../scwx/wsr88d/nexrad_file_factory.cpp | 21 +++---- 3 files changed, 48 insertions(+), 72 deletions(-) diff --git a/wxdata/source/scwx/wsr88d/ar2v_file.cpp b/wxdata/source/scwx/wsr88d/ar2v_file.cpp index 37de5472..7b064de9 100644 --- a/wxdata/source/scwx/wsr88d/ar2v_file.cpp +++ b/wxdata/source/scwx/wsr88d/ar2v_file.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -10,14 +11,14 @@ #include #include #include -#include namespace scwx { namespace wsr88d { -static const std::string logPrefix_ = "[scwx::wsr88d::ar2v_file] "; +static const std::string logPrefix_ = "scwx::wsr88d::ar2v_file"; +static const auto logger_ = util::Logger::Create(logPrefix_); class Ar2vFileImpl { @@ -115,8 +116,7 @@ Ar2vFile::GetElevationScan(rda::DataBlockType dataBlockType, float elevation, std::chrono::system_clock::time_point time) const { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "GetElevationScan: " << elevation << " degrees"; + logger_->debug("GetElevationScan: {} degrees", elevation); constexpr float scaleFactor = 8.0f / 0.043945f; @@ -170,14 +170,13 @@ Ar2vFile::GetElevationScan(rda::DataBlockType dataBlockType, bool Ar2vFile::LoadFile(const std::string& filename) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")"; + logger_->debug("LoadFile: {}", filename); bool fileValid = true; std::ifstream f(filename, std::ios_base::in | std::ios_base::binary); if (!f.good()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not open file for reading: " << filename; + logger_->warn("Could not open file for reading: {}", filename); fileValid = false; } @@ -191,7 +190,7 @@ bool Ar2vFile::LoadFile(const std::string& filename) bool Ar2vFile::LoadData(std::istream& is) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Data"; + logger_->debug("Loading Data"); bool dataValid = true; @@ -211,21 +210,17 @@ bool Ar2vFile::LoadData(std::istream& is) if (is.eof()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not read Volume Header Record\n"; + logger_->warn("Could not read Volume Header Record"); dataValid = false; } if (dataValid) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Filename: " << p->tapeFilename_; - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Extension: " << p->extensionNumber_; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Date: " << p->julianDate_; - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Time: " << p->milliseconds_; - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ICAO: " << p->icao_; + logger_->debug("Filename: {}", p->tapeFilename_); + logger_->debug("Extension: {}", p->extensionNumber_); + logger_->debug("Date: {}", p->julianDate_); + logger_->debug("Time: {}", p->milliseconds_); + logger_->debug("ICAO: {}", p->icao_); size_t decompressedRecords = p->DecompressLDMRecords(is); if (decompressedRecords == 0) @@ -245,7 +240,7 @@ bool Ar2vFile::LoadData(std::istream& is) size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Decompressing LDM Records"; + logger_->debug("Decompressing LDM Records"); size_t numRecords = 0; @@ -260,8 +255,7 @@ size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is) controlWord = ntohl(controlWord); recordSize = std::abs(controlWord); - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "LDM Record Found: Size = " << recordSize << " bytes"; + logger_->trace("LDM Record Found: Size = {} bytes", recordSize); if (recordSize == 0) { @@ -278,17 +272,14 @@ size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is) { std::stringstream ss; std::streamsize bytesCopied = boost::iostreams::copy(in, ss); - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Decompressed record size = " << bytesCopied - << " bytes"; + logger_->trace("Decompressed record size = {} bytes", bytesCopied); rawRecords_.push_back(std::move(ss)); } catch (const boost::iostreams::bzip2_error& ex) { int error = ex.error(); - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Error decompressing record " << numRecords; + logger_->warn("Error decompressing record {}", numRecords); is.seekg(startPosition + std::streampos(recordSize), std::ios_base::beg); @@ -297,15 +288,14 @@ size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is) ++numRecords; } - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Decompressed " << numRecords << " LDM Records"; + logger_->debug("Decompressed {} LDM Records", numRecords); return numRecords; } void Ar2vFileImpl::ParseLDMRecords() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Parsing LDM Records"; + logger_->debug("Parsing LDM Records"); size_t count = 0; @@ -313,7 +303,7 @@ void Ar2vFileImpl::ParseLDMRecords() { std::stringstream& ss = *it; - BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Record " << count++; + logger_->trace("Record {}", count++); ParseLDMRecord(ss); } @@ -346,8 +336,7 @@ void Ar2vFileImpl::ParseLDMRecord(std::istream& is) if (!is.eof() && offset != 0) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Next record offset by " << offset << " bytes"; + logger_->trace("Next record offset by {} bytes", offset); } else if (is.eof()) { @@ -382,7 +371,8 @@ void Ar2vFileImpl::HandleMessage(std::shared_ptr& message) std::static_pointer_cast(message)); break; - default: break; + default: + break; } } @@ -402,12 +392,11 @@ void Ar2vFileImpl::ProcessRadarData( void Ar2vFileImpl::IndexFile() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Indexing file"; + logger_->debug("Indexing file"); if (vcpData_ == nullptr) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Cannot index file without VCP data"; + logger_->warn("Cannot index file without VCP data"); return; } diff --git a/wxdata/source/scwx/wsr88d/level3_file.cpp b/wxdata/source/scwx/wsr88d/level3_file.cpp index 46508b7c..eb5613fc 100644 --- a/wxdata/source/scwx/wsr88d/level3_file.cpp +++ b/wxdata/source/scwx/wsr88d/level3_file.cpp @@ -1,20 +1,21 @@ #include #include #include +#include #include #include #include #include -#include namespace scwx { namespace wsr88d { -static const std::string logPrefix_ = "[scwx::wsr88d::level3_file] "; +static const std::string logPrefix_ = "scwx::wsr88d::level3_file"; +static const auto logger_ = util::Logger::Create(logPrefix_); class Level3FileImpl { @@ -50,14 +51,13 @@ std::shared_ptr Level3File::message() const bool Level3File::LoadFile(const std::string& filename) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")"; + logger_->debug("LoadFile: {}", filename); bool fileValid = true; std::ifstream f(filename, std::ios_base::in | std::ios_base::binary); if (!f.good()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not open file for reading: " << filename; + logger_->warn("Could not open file for reading: {}", filename); fileValid = false; } @@ -71,7 +71,7 @@ bool Level3File::LoadFile(const std::string& filename) bool Level3File::LoadData(std::istream& is) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Data"; + logger_->debug("Loading Data"); p->wmoHeader_ = std::make_shared(); @@ -79,16 +79,11 @@ bool Level3File::LoadData(std::istream& is) if (dataValid) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Data Type: " << p->wmoHeader_->data_type(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "ICAO: " << p->wmoHeader_->icao(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Date/Time: " << p->wmoHeader_->date_time(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Category: " << p->wmoHeader_->product_category(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Site ID: " << p->wmoHeader_->product_designator(); + logger_->debug("Data Type: {}", p->wmoHeader_->data_type()); + logger_->debug("ICAO: {}", p->wmoHeader_->icao()); + logger_->debug("Date/Time: {}", p->wmoHeader_->date_time()); + logger_->debug("Category: {}", p->wmoHeader_->product_category()); + logger_->debug("Site ID: {}", p->wmoHeader_->product_designator()); // If the header is compressed if (is.peek() == 0x78) @@ -146,20 +141,15 @@ bool Level3FileImpl::DecompressFile(std::istream& is, std::stringstream& ss) { int error = ex.error(); - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Error decompressing data: " << ex.what(); + logger_->warn("Error decompressing data: {}", ex.what()); dataValid = false; } if (dataValid) { - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Input data consumed = " << totalBytesCopied - << " bytes"; - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Decompressed data size = " << totalBytesConsumed - << " bytes"; + logger_->trace("Input data consumed = {} bytes", totalBytesCopied); + logger_->trace("Decompressed data size = {} bytes", totalBytesConsumed); ccbHeader_ = std::make_shared(); dataValid = ccbHeader_->Parse(ss); diff --git a/wxdata/source/scwx/wsr88d/nexrad_file_factory.cpp b/wxdata/source/scwx/wsr88d/nexrad_file_factory.cpp index 08aa2b72..7d46a83f 100644 --- a/wxdata/source/scwx/wsr88d/nexrad_file_factory.cpp +++ b/wxdata/source/scwx/wsr88d/nexrad_file_factory.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -8,19 +9,19 @@ #include #include #include -#include namespace scwx { namespace wsr88d { -static const std::string logPrefix_ = "[scwx::wsr88d::nexrad_file_factory] "; +static const std::string logPrefix_ = "scwx::wsr88d::nexrad_file_factory"; +static const auto logger_ = util::Logger::Create(logPrefix_); std::shared_ptr NexradFileFactory::Create(const std::string& filename) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Create(" << filename << ")"; + logger_->debug("Create: {}", filename); std::shared_ptr nexradFile = nullptr; bool fileValid = true; @@ -28,8 +29,7 @@ NexradFileFactory::Create(const std::string& filename) std::ifstream f(filename, std::ios_base::in | std::ios_base::binary); if (!f.good()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not open file for reading: " << filename; + logger_->warn("Could not open file for reading: {}", filename); fileValid = false; } @@ -74,26 +74,23 @@ std::shared_ptr NexradFileFactory::Create(std::istream& is) dataValid = ss.good(); ss.seekg(pisBegin, std::ios_base::beg); - BOOST_LOG_TRIVIAL(trace) - << logPrefix_ << "Decompressed file = " << bytesCopied << " bytes"; + logger_->trace("Decompressed file = {} bytes", bytesCopied); if (!dataValid) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Error reading decompressed stream"; + logger_->warn("Error reading decompressed stream"); } } catch (const boost::iostreams::gzip_error& ex) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Error decompressing file: " << ex.what(); + logger_->warn("Error decompressing file: {}", ex.what()); dataValid = false; } } else if (!dataValid) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Error reading file"; + logger_->warn("Error reading file"); } if (dataValid) From 15bc3afc8735dd2a08d16f92acd04f61f754a879 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 18 Apr 2022 08:39:24 -0500 Subject: [PATCH 07/13] Boost.Log -> spdlog - config, gl, manager --- scwx-qt/source/scwx/qt/config/radar_site.cpp | 17 ++++---- scwx-qt/source/scwx/qt/gl/draw/draw_item.cpp | 4 +- scwx-qt/source/scwx/qt/gl/draw/rectangle.cpp | 4 +- scwx-qt/source/scwx/qt/gl/shader_program.cpp | 33 ++++++---------- scwx-qt/source/scwx/qt/gl/text_shader.cpp | 7 ++-- .../scwx/qt/manager/radar_product_manager.cpp | 39 ++++++++----------- .../scwx/qt/manager/settings_manager.cpp | 15 ++++--- 7 files changed, 51 insertions(+), 68 deletions(-) diff --git a/scwx-qt/source/scwx/qt/config/radar_site.cpp b/scwx-qt/source/scwx/qt/config/radar_site.cpp index dcc82384..75d084b5 100644 --- a/scwx-qt/source/scwx/qt/config/radar_site.cpp +++ b/scwx-qt/source/scwx/qt/config/radar_site.cpp @@ -1,11 +1,10 @@ #include #include #include +#include #include -#include - namespace scwx { namespace qt @@ -13,7 +12,8 @@ namespace qt namespace config { -static const std::string logPrefix_ = "[scwx::qt::settings::radar_site] "; +static const std::string logPrefix_ = "scwx::qt::settings::radar_site"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static const std::string defaultRadarSiteFile_ = ":/res/config/radar_sites.json"; @@ -121,8 +121,7 @@ void RadarSite::Initialize() size_t RadarSite::ReadConfig(const std::string& path) { - BOOST_LOG_TRIVIAL(info) << logPrefix_ << "Loading radar sites from \"" - << path << "\"..."; + logger_->info("Loading radar sites from \"{}\"...", path); bool dataValid = true; size_t sitesAdded = 0; @@ -139,7 +138,7 @@ size_t RadarSite::ReadConfig(const std::string& path) if (!ValidateJsonEntry(o)) { - BOOST_LOG_TRIVIAL(info) << logPrefix_ << "Incorrect format: " << v; + logger_->info("Incorrect format: {}", boost::json::serialize(v)); } else { @@ -168,9 +167,9 @@ size_t RadarSite::ReadConfig(const std::string& path) } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Site ID conflict: " << siteIdMap_.at(siteId) - << " and " << site->p->id_; + logger_->warn("Site ID conflict: {} and {}", + siteIdMap_.at(siteId), + site->p->id_); } } } diff --git a/scwx-qt/source/scwx/qt/gl/draw/draw_item.cpp b/scwx-qt/source/scwx/qt/gl/draw/draw_item.cpp index 83c9d951..ca4533b6 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/draw_item.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/draw_item.cpp @@ -1,6 +1,6 @@ #include -#include +#include namespace scwx { @@ -11,7 +11,7 @@ namespace gl namespace draw { -static const std::string logPrefix_ = "[scwx::qt::gl::draw::draw_item] "; +static const std::string logPrefix_ = "scwx::qt::gl::draw::draw_item"; class DrawItemImpl { diff --git a/scwx-qt/source/scwx/qt/gl/draw/rectangle.cpp b/scwx-qt/source/scwx/qt/gl/draw/rectangle.cpp index 89fcba66..10988613 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/rectangle.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/rectangle.cpp @@ -2,8 +2,6 @@ #include -#include - namespace scwx { namespace qt @@ -13,7 +11,7 @@ namespace gl namespace draw { -static const std::string logPrefix_ = "[scwx::qt::gl::draw::rectangle] "; +static const std::string logPrefix_ = "scwx::qt::gl::draw::rectangle"; static constexpr size_t NUM_RECTANGLES = 5; static constexpr size_t NUM_TRIANGLES = NUM_RECTANGLES * 2; diff --git a/scwx-qt/source/scwx/qt/gl/shader_program.cpp b/scwx-qt/source/scwx/qt/gl/shader_program.cpp index f7460077..bbf0a73b 100644 --- a/scwx-qt/source/scwx/qt/gl/shader_program.cpp +++ b/scwx-qt/source/scwx/qt/gl/shader_program.cpp @@ -1,9 +1,8 @@ #include +#include #include -#include - namespace scwx { namespace qt @@ -11,7 +10,8 @@ namespace qt namespace gl { -static const std::string logPrefix_ = "[scwx::qt::gl::shader_program] "; +static const std::string logPrefix_ = "scwx::qt::gl::shader_program"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static constexpr GLsizei INFO_LOG_BUF_SIZE = 512; @@ -53,8 +53,7 @@ GLuint ShaderProgram::id() const bool ShaderProgram::Load(const std::string& vertexPath, const std::string& fragmentPath) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Load(\"" << vertexPath << "\", \"" - << fragmentPath << "\")"; + logger_->debug("Load: {}, {}", vertexPath, fragmentPath); OpenGLFunctions& gl = p->gl_; @@ -71,15 +70,13 @@ bool ShaderProgram::Load(const std::string& vertexPath, if (!vertexFile.isOpen()) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Could not load vertex shader: " << vertexPath; + logger_->error("Could not load vertex shader: {}", vertexPath); return false; } if (!fragmentFile.isOpen()) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Could not load fragment shader: " << fragmentPath; + logger_->error("Could not load fragment shader: {}", fragmentPath); return false; } @@ -108,14 +105,12 @@ bool ShaderProgram::Load(const std::string& vertexPath, gl.glGetShaderInfoLog(vertexShader, INFO_LOG_BUF_SIZE, &logLength, infoLog); if (!glSuccess) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Vertex shader compilation failed: " << infoLog; + logger_->error("Vertex shader compilation failed: {}", infoLog); success = false; } else if (logLength > 0) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Vertex shader compiled with warnings: " << infoLog; + logger_->error("Vertex shader compiled with warnings: {}", infoLog); } // Create a fragment shader @@ -131,14 +126,12 @@ bool ShaderProgram::Load(const std::string& vertexPath, fragmentShader, INFO_LOG_BUF_SIZE, &logLength, infoLog); if (!glSuccess) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Fragment shader compilation failed: " << infoLog; + logger_->error("Fragment shader compilation failed: {}", infoLog); success = false; } else if (logLength > 0) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Fragment shader compiled with warnings: " << infoLog; + logger_->error("Fragment shader compiled with warnings: {}", infoLog); } if (success) @@ -152,14 +145,12 @@ bool ShaderProgram::Load(const std::string& vertexPath, gl.glGetProgramInfoLog(p->id_, INFO_LOG_BUF_SIZE, &logLength, infoLog); if (!glSuccess) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Shader program link failed: " << infoLog; + logger_->error("Shader program link failed: {}", infoLog); success = false; } else if (logLength > 0) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Shader program linked with warnings: " << infoLog; + logger_->error("Shader program linked with warnings: {}", infoLog); } } diff --git a/scwx-qt/source/scwx/qt/gl/text_shader.cpp b/scwx-qt/source/scwx/qt/gl/text_shader.cpp index e8e83bb8..39120c94 100644 --- a/scwx-qt/source/scwx/qt/gl/text_shader.cpp +++ b/scwx-qt/source/scwx/qt/gl/text_shader.cpp @@ -1,6 +1,6 @@ #include +#include -#include #include namespace scwx @@ -10,7 +10,8 @@ namespace qt namespace gl { -static const std::string logPrefix_ = "[scwx::qt::gl::text_shader] "; +static const std::string logPrefix_ = "scwx::qt::gl::text_shader"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class TextShaderImpl { @@ -46,7 +47,7 @@ bool TextShader::Initialize() p->projectionLocation_ = gl.glGetUniformLocation(id(), "projection"); if (p->projectionLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Could not find projection"; + logger_->warn("Could not find projection"); } return success; diff --git a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp index a2bb45c5..425f24da 100644 --- a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -8,7 +9,6 @@ #include #include -#include #include #include #include @@ -22,7 +22,8 @@ namespace manager { static const std::string logPrefix_ = - "[scwx::qt::manager::radar_product_manager] "; + "scwx::qt::manager::radar_product_manager"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); typedef std::function()> CreateNexradFileFunction; @@ -59,8 +60,7 @@ public: { if (radarSite_ == nullptr) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Radar site not found: \"" << radarId_ << "\""; + logger_->warn("Radar site not found: \"{}\"", radarId_); radarSite_ = std::make_shared(); } } @@ -130,7 +130,7 @@ void RadarProductManager::Initialize() return; } - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; + logger_->debug("Initialize()"); boost::timer::cpu_timer timer; @@ -176,9 +176,8 @@ void RadarProductManager::Initialize() coordinates0_5Degree[offset + 1] = longitude; }); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Coordinates (0.5 degree) calculated in " - << timer.format(6, "%ws"); + logger_->debug("Coordinates (0.5 degree) calculated in {}", + timer.format(6, "%ws")); // Calculate 1 degree azimuth coordinates timer.start(); @@ -214,9 +213,8 @@ void RadarProductManager::Initialize() coordinates1Degree[offset + 1] = longitude; }); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Coordinates (1 degree) calculated in " - << timer.format(6, "%ws"); + logger_->debug("Coordinates (1 degree) calculated in {}", + timer.format(6, "%ws")); p->initialized_ = true; } @@ -224,7 +222,7 @@ void RadarProductManager::Initialize() void RadarProductManager::LoadData( std::istream& is, std::shared_ptr request) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadData()"; + logger_->debug("LoadData()"); RadarProductManagerImpl::LoadNexradFile( [=, &is]() -> std::shared_ptr @@ -236,7 +234,7 @@ void RadarProductManager::LoadFile( const std::string& filename, std::shared_ptr request) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")"; + logger_->debug("LoadFile: {}", filename); std::shared_ptr existingRecord = nullptr; @@ -245,8 +243,7 @@ void RadarProductManager::LoadFile( auto it = fileIndex_.find(filename); if (it != fileIndex_.cend()) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "File previously loaded, loading from file cache"; + logger_->debug("File previously loaded, loading from file cache"); existingRecord = it->second; } @@ -385,7 +382,7 @@ std::shared_ptr RadarProductManagerImpl::StoreRadarProductRecord( std::shared_ptr record) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "StoreRadarProductRecord()"; + logger_->debug("StoreRadarProductRecord()"); std::shared_ptr storedRecord = record; @@ -394,9 +391,8 @@ RadarProductManagerImpl::StoreRadarProductRecord( auto it = level2ProductRecords_.find(record->time()); if (it != level2ProductRecords_.cend()) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ - << "Level 2 product previously loaded, loading from cache"; + logger_->debug( + "Level 2 product previously loaded, loading from cache"); storedRecord = it->second; } @@ -412,9 +408,8 @@ RadarProductManagerImpl::StoreRadarProductRecord( auto it = productMap.find(record->time()); if (it != productMap.cend()) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ - << "Level 3 product previously loaded, loading from cache"; + logger_->debug( + "Level 3 product previously loaded, loading from cache"); storedRecord = it->second; } diff --git a/scwx-qt/source/scwx/qt/manager/settings_manager.cpp b/scwx-qt/source/scwx/qt/manager/settings_manager.cpp index de4e7842..04b258ee 100644 --- a/scwx-qt/source/scwx/qt/manager/settings_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/settings_manager.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -7,8 +8,6 @@ #include #include -#include - namespace scwx { namespace qt @@ -18,7 +17,8 @@ namespace manager namespace SettingsManager { -static const std::string logPrefix_ = "[scwx::qt::manager::settings_manager] "; +static const std::string logPrefix_ = "scwx::qt::manager::settings_manager"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static std::shared_ptr generalSettings_ = nullptr; static std::shared_ptr paletteSettings_ = nullptr; @@ -37,9 +37,8 @@ void Initialize() { if (!std::filesystem::create_directories(appDataPath)) { - BOOST_LOG_TRIVIAL(error) - << logPrefix_ << "Unable to create application data directory: \"" - << appDataPath << "\""; + logger_->error("Unable to create application data directory: \"{}\"", + appDataPath); } } @@ -97,7 +96,7 @@ static boost::json::value ConvertSettingsToJson() static void GenerateDefaultSettings() { - BOOST_LOG_TRIVIAL(info) << logPrefix_ << "Generating default settings"; + logger_->info("Generating default settings"); generalSettings_ = settings::GeneralSettings::Create(); paletteSettings_ = settings::PaletteSettings::Create(); @@ -105,7 +104,7 @@ static void GenerateDefaultSettings() static bool LoadSettings(const boost::json::object& settingsJson) { - BOOST_LOG_TRIVIAL(info) << logPrefix_ << "Loading settings"; + logger_->info("Loading settings"); bool jsonDirty = false; From e6bddc79dbc0f40501d6d82121d6e19e6ac083a1 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 18 Apr 2022 09:09:02 -0500 Subject: [PATCH 08/13] Boost.Log -> spdlog - qt/map --- scwx-qt/source/scwx/qt/gl/gl.hpp | 3 +- .../source/scwx/qt/map/color_table_layer.cpp | 11 ++--- scwx-qt/source/scwx/qt/map/draw_layer.cpp | 7 ++-- scwx-qt/source/scwx/qt/map/map_widget.cpp | 18 ++++----- scwx-qt/source/scwx/qt/map/overlay_layer.cpp | 9 +++-- .../scwx/qt/map/radar_product_layer.cpp | 40 +++++++++---------- .../source/scwx/qt/map/radar_range_layer.cpp | 7 ++-- 7 files changed, 47 insertions(+), 48 deletions(-) diff --git a/scwx-qt/source/scwx/qt/gl/gl.hpp b/scwx-qt/source/scwx/qt/gl/gl.hpp index 03c8d3cf..e87454c8 100644 --- a/scwx-qt/source/scwx/qt/gl/gl.hpp +++ b/scwx-qt/source/scwx/qt/gl/gl.hpp @@ -7,8 +7,7 @@ GLenum err; \ while ((err = gl.glGetError()) != GL_NO_ERROR) \ { \ - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "GL Error: " << err \ - << ", " __FILE__ << ":" << __LINE__; \ + logger_->error("GL Error: {}, {}: {}", err, __FILE__, __LINE__); \ } \ } diff --git a/scwx-qt/source/scwx/qt/map/color_table_layer.cpp b/scwx-qt/source/scwx/qt/map/color_table_layer.cpp index 3c67b5b4..a02b97ca 100644 --- a/scwx-qt/source/scwx/qt/map/color_table_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/color_table_layer.cpp @@ -1,7 +1,7 @@ #include #include +#include -#include #include #include @@ -12,7 +12,8 @@ namespace qt namespace map { -static const std::string logPrefix_ = "[scwx::qt::map::color_table_layer] "; +static const std::string logPrefix_ = "scwx::qt::map::color_table_layer"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class ColorTableLayerImpl { @@ -47,7 +48,7 @@ ColorTableLayer::~ColorTableLayer() = default; void ColorTableLayer::Initialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; + logger_->debug("Initialize()"); gl::OpenGLFunctions& gl = context()->gl_; @@ -58,7 +59,7 @@ void ColorTableLayer::Initialize() gl.glGetUniformLocation(p->shaderProgram_.id(), "uMVPMatrix"); if (p->uMVPMatrixLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Could not find uMVPMatrix"; + logger_->warn("Could not find uMVPMatrix"); } gl.glGenTextures(1, &p->texture_); @@ -170,7 +171,7 @@ void ColorTableLayer::Render(const QMapbox::CustomLayerRenderParameters& params) void ColorTableLayer::Deinitialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Deinitialize()"; + logger_->debug("Deinitialize()"); gl::OpenGLFunctions& gl = context()->gl_; diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.cpp b/scwx-qt/source/scwx/qt/map/draw_layer.cpp index 409ddfe2..8a4e4bfb 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.cpp @@ -1,7 +1,7 @@ #include #include +#include -#include #include #include #include @@ -13,7 +13,8 @@ namespace qt namespace map { -static const std::string logPrefix_ = "[scwx::qt::map::draw_layer] "; +static const std::string logPrefix_ = "scwx::qt::map::draw_layer"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class DrawLayerImpl { @@ -47,7 +48,7 @@ void DrawLayer::Initialize() gl.glGetUniformLocation(p->shaderProgram_.id(), "uMVPMatrix"); if (p->uMVPMatrixLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Could not find uMVPMatrix"; + logger_->warn("Could not find uMVPMatrix"); } p->shaderProgram_.Use(); diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index d554a327..fab66022 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -20,8 +21,6 @@ #include #include -#include - namespace scwx { namespace qt @@ -29,7 +28,8 @@ namespace qt namespace map { -static const std::string logPrefix_ = "[scwx::qt::map::map_widget] "; +static const std::string logPrefix_ = "scwx::qt::map::map_widget"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); typedef std::pair MapStyle; @@ -309,10 +309,11 @@ void MapWidget::SelectRadarProduct( productCode = level3File->message()->header().message_code(); } - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "SelectRadarProduct(" << radarId << ", " - << common::GetRadarProductGroupName(group) << ", " << product << ", " - << util::TimeString(time) << ")"; + logger_->debug("SelectRadarProduct: {}, {}, {}, {}", + radarId, + common::GetRadarProductGroupName(group), + product, + util::TimeString(time)); if (group == common::RadarProductGroup::Level2) { @@ -335,8 +336,7 @@ void MapWidget::SelectRadarProduct( if (radarProductView == nullptr) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "No view created for product"; + logger_->debug("No view created for product"); return; } diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp index 02010f97..4b340ec9 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -10,7 +11,6 @@ #include #include -#include #include #include #include @@ -25,7 +25,8 @@ namespace qt namespace map { -static const std::string logPrefix_ = "[scwx::qt::map::overlay_layer] "; +static const std::string logPrefix_ = "scwx::qt::map::overlay_layer"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class OverlayLayerImpl { @@ -74,7 +75,7 @@ OverlayLayer::~OverlayLayer() = default; void OverlayLayer::Initialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; + logger_->debug("Initialize()"); DrawLayer::Initialize(); @@ -154,7 +155,7 @@ void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) void OverlayLayer::Deinitialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Deinitialize()"; + logger_->debug("Deinitialize()"); DrawLayer::Deinitialize(); diff --git a/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp index b9f02854..584e6619 100644 --- a/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_product_layer.cpp @@ -1,9 +1,9 @@ #include #include +#include #include -#include #include #include #include @@ -21,7 +21,8 @@ namespace map static constexpr uint32_t MAX_RADIALS = 720; static constexpr uint32_t MAX_DATA_MOMENT_GATES = 1840; -static const std::string logPrefix_ = "[scwx::qt::map::radar_product_layer] "; +static const std::string logPrefix_ = "scwx::qt::map::radar_product_layer"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static glm::vec2 LatLongToScreenCoordinate(const QMapbox::Coordinate& coordinate); @@ -73,7 +74,7 @@ RadarProductLayer::~RadarProductLayer() = default; void RadarProductLayer::Initialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Initialize()"; + logger_->debug("Initialize()"); gl::OpenGLFunctions& gl = context()->gl_; @@ -84,38 +85,35 @@ void RadarProductLayer::Initialize() gl.glGetUniformLocation(p->shaderProgram_.id(), "uMVPMatrix"); if (p->uMVPMatrixLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Could not find uMVPMatrix"; + logger_->warn("Could not find uMVPMatrix"); } p->uMapScreenCoordLocation_ = gl.glGetUniformLocation(p->shaderProgram_.id(), "uMapScreenCoord"); if (p->uMapScreenCoordLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not find uMapScreenCoord"; + logger_->warn("Could not find uMapScreenCoord"); } p->uDataMomentOffsetLocation_ = gl.glGetUniformLocation(p->shaderProgram_.id(), "uDataMomentOffset"); if (p->uDataMomentOffsetLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not find uDataMomentOffset"; + logger_->warn("Could not find uDataMomentOffset"); } p->uDataMomentScaleLocation_ = gl.glGetUniformLocation(p->shaderProgram_.id(), "uDataMomentScale"); if (p->uDataMomentScaleLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not find uDataMomentScale"; + logger_->warn("Could not find uDataMomentScale"); } p->uCFPEnabledLocation_ = gl.glGetUniformLocation(p->shaderProgram_.id(), "uCFPEnabled"); if (p->uCFPEnabledLocation_ == -1) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Could not find uCFPEnabled"; + logger_->warn("Could not find uCFPEnabled"); } p->shaderProgram_.Use(); @@ -148,7 +146,7 @@ void RadarProductLayer::Initialize() void RadarProductLayer::UpdateSweep() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdateSweep()"; + logger_->debug("UpdateSweep()"); gl::OpenGLFunctions& gl = context()->gl_; @@ -161,8 +159,7 @@ void RadarProductLayer::UpdateSweep() std::try_to_lock); if (!sweepLock.owns_lock()) { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Sweep locked, deferring update"; + logger_->debug("Sweep locked, deferring update"); return; } @@ -181,8 +178,7 @@ void RadarProductLayer::UpdateSweep() vertices.data(), GL_STATIC_DRAW); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Vertices buffered in " << timer.format(6, "%ws"); + logger_->debug("Vertices buffered in {}", timer.format(6, "%ws")); gl.glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, static_cast(0)); gl.glEnableVertexAttribArray(0); @@ -208,8 +204,7 @@ void RadarProductLayer::UpdateSweep() timer.start(); gl.glBufferData(GL_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Data moments buffered in " << timer.format(6, "%ws"); + logger_->debug("Data moments buffered in {}", timer.format(6, "%ws")); gl.glVertexAttribIPointer(1, 1, type, 0, static_cast(0)); gl.glEnableVertexAttribArray(1); @@ -238,8 +233,7 @@ void RadarProductLayer::UpdateSweep() timer.start(); gl.glBufferData(GL_ARRAY_BUFFER, cfpDataSize, cfpData, GL_STATIC_DRAW); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "CFP moments buffered in " << timer.format(6, "%ws"); + logger_->debug("CFP moments buffered in {}", timer.format(6, "%ws")); gl.glVertexAttribIPointer(2, 1, cfpType, 0, static_cast(0)); gl.glEnableVertexAttribArray(2); @@ -294,11 +288,13 @@ void RadarProductLayer::Render( gl.glBindTexture(GL_TEXTURE_1D, p->texture_); gl.glBindVertexArray(p->vao_); gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_); + + SCWX_GL_CHECK_ERROR(); } void RadarProductLayer::Deinitialize() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Deinitialize()"; + logger_->debug("Deinitialize()"); gl::OpenGLFunctions& gl = context()->gl_; @@ -317,7 +313,7 @@ void RadarProductLayer::Deinitialize() void RadarProductLayer::UpdateColorTable() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "UpdateColorTable()"; + logger_->debug("UpdateColorTable()"); p->colorTableNeedsUpdate_ = false; diff --git a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp index 96798080..074b6339 100644 --- a/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/radar_range_layer.cpp @@ -1,6 +1,6 @@ #include +#include -#include #include #include @@ -11,7 +11,8 @@ namespace qt namespace map { -static const std::string logPrefix_ = "[scwx::qt::map::radar_range_layer] "; +static const std::string logPrefix_ = "scwx::qt::map::radar_range_layer"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static std::shared_ptr GetRangeCircle(float range, QMapbox::Coordinate center); @@ -21,7 +22,7 @@ void RadarRangeLayer::Add(std::shared_ptr map, QMapbox::Coordinate center, const QString& before) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Add()"; + logger_->debug("Add()"); if (map->layerExists("rangeCircleLayer")) { From c6281d799f1860fe291c7ad31c9cd0aa3ec1a3e0 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 19 Apr 2022 16:01:45 -0500 Subject: [PATCH 09/13] Removing boost log from Boost.Log -> spdlog - settings, types, util, view --- .../scwx/qt/request/nexrad_file_request.cpp | 5 +- .../scwx/qt/settings/general_settings.cpp | 12 ++-- .../scwx/qt/settings/palette_settings.cpp | 12 ++-- .../scwx/qt/types/radar_product_record.cpp | 5 +- scwx-qt/source/scwx/qt/util/font.cpp | 28 ++++---- scwx-qt/source/scwx/qt/util/font_buffer.cpp | 9 ++- scwx-qt/source/scwx/qt/util/json.cpp | 69 ++++++++++--------- .../scwx/qt/view/level2_product_view.cpp | 21 +++--- .../scwx/qt/view/level3_product_view.cpp | 3 +- .../scwx/qt/view/level3_radial_view.cpp | 26 +++---- .../scwx/qt/view/level3_raster_view.cpp | 25 +++---- .../scwx/qt/view/radar_product_view.cpp | 7 +- .../qt/view/radar_product_view_factory.cpp | 14 ++-- 13 files changed, 109 insertions(+), 127 deletions(-) diff --git a/scwx-qt/source/scwx/qt/request/nexrad_file_request.cpp b/scwx-qt/source/scwx/qt/request/nexrad_file_request.cpp index af39c1da..5324027f 100644 --- a/scwx-qt/source/scwx/qt/request/nexrad_file_request.cpp +++ b/scwx-qt/source/scwx/qt/request/nexrad_file_request.cpp @@ -1,7 +1,5 @@ #include -#include - namespace scwx { namespace qt @@ -9,8 +7,7 @@ namespace qt namespace request { -static const std::string logPrefix_ = - "[scwx::qt::request::nexrad_file_request] "; +static const std::string logPrefix_ = "scwx::qt::request::nexrad_file_request"; class NexradFileRequestImpl { diff --git a/scwx-qt/source/scwx/qt/settings/general_settings.cpp b/scwx-qt/source/scwx/qt/settings/general_settings.cpp index e1a41dbf..bc921075 100644 --- a/scwx-qt/source/scwx/qt/settings/general_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/general_settings.cpp @@ -1,7 +1,6 @@ #include #include - -#include +#include namespace scwx { @@ -10,7 +9,8 @@ namespace qt namespace settings { -static const std::string logPrefix_ = "[scwx::qt::settings::general_settings] "; +static const std::string logPrefix_ = "scwx::qt::settings::general_settings"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static const std::string DEFAULT_DEFAULT_RADAR_SITE = "KLSX"; static const int64_t DEFAULT_GRID_WIDTH = 1; @@ -115,13 +115,11 @@ GeneralSettings::Load(const boost::json::value* json, bool& jsonDirty) { if (json == nullptr) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Key is not present, resetting to defaults"; + logger_->warn("Key is not present, resetting to defaults"); } else if (!json->is_object()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid json, resetting to defaults"; + logger_->warn("Invalid json, resetting to defaults"); } generalSettings->p->SetDefaults(); diff --git a/scwx-qt/source/scwx/qt/settings/palette_settings.cpp b/scwx-qt/source/scwx/qt/settings/palette_settings.cpp index 7e1a42b3..241e0048 100644 --- a/scwx-qt/source/scwx/qt/settings/palette_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/palette_settings.cpp @@ -1,7 +1,6 @@ #include #include - -#include +#include namespace scwx { @@ -10,7 +9,8 @@ namespace qt namespace settings { -static const std::string logPrefix_ = "[scwx::qt::settings::palette_settings] "; +static const std::string logPrefix_ = "scwx::qt::settings::palette_settings"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static const std::vector paletteNames_ = { // Level 2 / Common Products @@ -125,13 +125,11 @@ PaletteSettings::Load(const boost::json::value* json, bool& jsonDirty) { if (json == nullptr) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Key is not present, resetting to defaults"; + logger_->warn("Key is not present, resetting to defaults"); } else if (!json->is_object()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid json, resetting to defaults"; + logger_->warn("Invalid json, resetting to defaults"); } generalSettings->p->SetDefaults(); diff --git a/scwx-qt/source/scwx/qt/types/radar_product_record.cpp b/scwx-qt/source/scwx/qt/types/radar_product_record.cpp index 0262a452..daf4a306 100644 --- a/scwx-qt/source/scwx/qt/types/radar_product_record.cpp +++ b/scwx-qt/source/scwx/qt/types/radar_product_record.cpp @@ -3,8 +3,6 @@ #include #include -#include - namespace scwx { namespace qt @@ -12,8 +10,7 @@ namespace qt namespace types { -static const std::string logPrefix_ = - "[scwx::qt::types::radar_product_record] "; +static const std::string logPrefix_ = "scwx::qt::types::radar_product_record"; class RadarProductRecordImpl { diff --git a/scwx-qt/source/scwx/qt/util/font.cpp b/scwx-qt/source/scwx/qt/util/font.cpp index b29506bd..0078d016 100644 --- a/scwx-qt/source/scwx/qt/util/font.cpp +++ b/scwx-qt/source/scwx/qt/util/font.cpp @@ -2,11 +2,11 @@ #define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING #include +#include #include #include -#include #include #include #include @@ -76,7 +76,8 @@ static const std::string CODEPOINTS = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" "`abcdefghijklmnopqrstuvwxyz{|}~"; -static const std::string logPrefix_ = "[scwx::qt::util::font] "; +static const std::string logPrefix_ = "scwx::qt::util::font"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static constexpr float BASE_POINT_SIZE = 72.0f; static constexpr float POINT_SCALE = 1.0f / BASE_POINT_SIZE; @@ -144,9 +145,8 @@ float Font::BufferText(std::shared_ptr buffer, auto it = p->glyphs_.find(c); if (it == p->glyphs_.end()) { - BOOST_LOG_TRIVIAL(info) - << logPrefix_ - << "Could not draw character: " << static_cast(c); + logger_->info("Could not draw character: {}", + static_cast(c)); continue; } @@ -198,9 +198,7 @@ float Font::TextLength(const std::string& text, float pointSize) const auto it = p->glyphs_.find(c); if (it == p->glyphs_.end()) { - BOOST_LOG_TRIVIAL(info) - << logPrefix_ - << "Character not found: " << static_cast(c); + logger_->info("Character not found: {}", static_cast(c)); continue; } @@ -242,7 +240,7 @@ GLuint Font::GenerateTexture(gl::OpenGLFunctions& gl) std::shared_ptr Font::Create(const std::string& resource) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading font file: " << resource; + logger_->debug("Loading font file: {}", resource); std::shared_ptr font = nullptr; boost::timer::cpu_timer timer; @@ -250,7 +248,7 @@ std::shared_ptr Font::Create(const std::string& resource) auto it = fontMap_.find(resource); if (it != fontMap_.end()) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Font already created"; + logger_->debug("Font already created"); return it->second; } @@ -258,7 +256,7 @@ std::shared_ptr Font::Create(const std::string& resource) fontFile.open(QIODevice::ReadOnly); if (!fontFile.isOpen()) { - BOOST_LOG_TRIVIAL(error) << logPrefix_ << "Could not read font file"; + logger_->error("Could not read font file"); return font; } @@ -298,8 +296,7 @@ std::shared_ptr Font::Create(const std::string& resource) } } - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Font loaded in " << timer.format(6, "%ws"); + logger_->debug("Font loaded in {}", timer.format(6, "%ws")); texture_font_delete(textureFont); @@ -337,9 +334,8 @@ void FontImpl::ParseNames(FT_Face face) } } - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Font family: " << fontData_.fontFamily_ << " (" - << fontData_.fontSubfamily_ << ")"; + logger_->debug( + "Font family: {} ({})", fontData_.fontFamily_, fontData_.fontSubfamily_); } static void ParseSfntName(const FT_SfntName& sfntName, std::string& str) diff --git a/scwx-qt/source/scwx/qt/util/font_buffer.cpp b/scwx-qt/source/scwx/qt/util/font_buffer.cpp index 92fd0a3a..53e88aff 100644 --- a/scwx-qt/source/scwx/qt/util/font_buffer.cpp +++ b/scwx-qt/source/scwx/qt/util/font_buffer.cpp @@ -1,9 +1,8 @@ #include +#include #include -#include - namespace scwx { namespace qt @@ -11,7 +10,8 @@ namespace qt namespace util { -static const std::string logPrefix_ = "[scwx::qt::util::font_buffer] "; +static const std::string logPrefix_ = "scwx::qt::util::font_buffer"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class FontBufferImpl { @@ -140,8 +140,7 @@ void FontBuffer::Push(std::initializer_list indices, { if (indices.size() % 3 != 0 || vertices.size() % 9 != 0) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Invalid push arguments, ignoring"; + logger_->warn("Invalid push arguments, ignoring"); return; } diff --git a/scwx-qt/source/scwx/qt/util/json.cpp b/scwx-qt/source/scwx/qt/util/json.cpp index 538a80ff..0a512b7e 100644 --- a/scwx-qt/source/scwx/qt/util/json.cpp +++ b/scwx-qt/source/scwx/qt/util/json.cpp @@ -1,8 +1,8 @@ #include +#include #include -#include #include #include @@ -15,7 +15,8 @@ namespace util namespace json { -static const std::string logPrefix_ = "[scwx::qt::util::json] "; +static const std::string logPrefix_ = "scwx::qt::util::json"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); /* Adapted from: * https://www.boost.org/doc/libs/1_77_0/libs/json/doc/html/json/examples.html#json.examples.pretty @@ -50,16 +51,18 @@ bool FromJsonInt64(const boost::json::object& json, if (minValue.has_value() && value < *minValue) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << key << " less than minimum (" << value << " < " - << *minValue << "), setting to: " << *minValue; + logger_->warn("{} less than minimum ({} < {}), setting to: {2}", + key, + value, + *minValue); value = *minValue; } else if (maxValue.has_value() && value > *maxValue) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << key << " greater than maximum (" << value - << " > " << *maxValue << "), setting to: " << *maxValue; + logger_->warn("{} greater than maximum ({} > {}), setting to: {2}", + key, + value, + *maxValue); value = *maxValue; } else @@ -69,17 +72,17 @@ bool FromJsonInt64(const boost::json::object& json, } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << key << " is not an int64 (" << jv->kind() - << "), setting to default:" << defaultValue; + logger_->warn("{} is not an int64 ({}), setting to default: {}", + key, + jv->kind(), + defaultValue); value = defaultValue; } } else { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << key - << " is not present, setting to default: " << defaultValue; + logger_->debug( + "{} is not present, setting to default: {}", key, defaultValue); value = defaultValue; } @@ -103,17 +106,15 @@ bool FromJsonString(const boost::json::object& json, } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << key - << " is not a string, setting to default: " << defaultValue; + logger_->warn( + "{} is not a string, setting to default: {}", key, defaultValue); value = defaultValue; } } else { - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << key - << " is not present, setting to default: " << defaultValue; + logger_->debug( + "{} is not present, setting to default: {}", key, defaultValue); value = defaultValue; } @@ -156,9 +157,8 @@ static boost::json::value ReadJsonFile(QFile& file) } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Could not open file for reading: \"" - << file.fileName().toStdString() << "\""; + logger_->warn("Could not open file for reading: \"{}\"", + file.fileName().toStdString()); } return json; @@ -176,7 +176,7 @@ static boost::json::value ReadJsonStream(std::istream& is) p.write(line, ec); if (ec) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << ec.message(); + logger_->warn("{}", ec.message()); return nullptr; } } @@ -184,7 +184,7 @@ static boost::json::value ReadJsonStream(std::istream& is) p.finish(ec); if (ec) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << ec.message(); + logger_->warn("{}", ec.message()); return nullptr; } @@ -199,8 +199,7 @@ void WriteJsonFile(const std::string& path, if (!ofs.is_open()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Cannot write JSON file: \"" << path << "\""; + logger_->warn("Cannot write JSON file: \"{}\"", path); } else { @@ -277,11 +276,17 @@ static void PrettyPrintJson(std::ostream& os, break; } - case boost::json::kind::uint64: os << jv.get_uint64(); break; + case boost::json::kind::uint64: + os << jv.get_uint64(); + break; - case boost::json::kind::int64: os << jv.get_int64(); break; + case boost::json::kind::int64: + os << jv.get_int64(); + break; - case boost::json::kind::double_: os << jv.get_double(); break; + case boost::json::kind::double_: + os << jv.get_double(); + break; case boost::json::kind::bool_: if (jv.get_bool()) @@ -290,7 +295,9 @@ static void PrettyPrintJson(std::ostream& os, os << "false"; break; - case boost::json::kind::null: os << "null"; break; + case boost::json::kind::null: + os << "null"; + break; } if (indent->empty()) diff --git a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp index 6158da0c..16ce2296 100644 --- a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp @@ -1,9 +1,9 @@ #include #include +#include #include #include -#include #include #include @@ -14,7 +14,8 @@ namespace qt namespace view { -static const std::string logPrefix_ = "[scwx::qt::view::level2_product_view] "; +static const std::string logPrefix_ = "scwx::qt::view::level2_product_view"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static constexpr uint16_t RANGE_FOLDED = 1u; static constexpr uint32_t VERTICES_PER_BIN = 6u; @@ -73,8 +74,8 @@ public: } else { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Unknown product: \"" - << common::GetLevel2Name(product) << "\""; + logger_->warn("Unknown product: \"{}\"", + common::GetLevel2Name(product)); dataBlockType_ = wsr88d::rda::DataBlockType::Unknown; } } @@ -347,7 +348,7 @@ void Level2ProductView::UpdateColorTable() void Level2ProductView::ComputeSweep() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ComputeSweep()"; + logger_->debug("ComputeSweep()"); boost::timer::cpu_timer timer; @@ -382,8 +383,8 @@ void Level2ProductView::ComputeSweep() if (momentData0 == nullptr) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "No moment data for " - << common::GetLevel2Name(p->product_); + logger_->warn("No moment data for {}", + common::GetLevel2Name(p->product_)); return; } @@ -462,8 +463,7 @@ void Level2ProductView::ComputeSweep() if (momentData0->data_word_size() != momentData->data_word_size()) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Radial " << radial << " has different word size"; + logger_->warn("Radial {} has different word size", radial); continue; } @@ -632,8 +632,7 @@ void Level2ProductView::ComputeSweep() } timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Vertices calculated in " << timer.format(6, "%ws"); + logger_->debug("Vertices calculated in {}", timer.format(6, "%ws")); UpdateColorTable(); diff --git a/scwx-qt/source/scwx/qt/view/level3_product_view.cpp b/scwx-qt/source/scwx/qt/view/level3_product_view.cpp index 5f380044..875fae99 100644 --- a/scwx-qt/source/scwx/qt/view/level3_product_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_product_view.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -17,7 +16,7 @@ namespace qt namespace view { -static const std::string logPrefix_ = "[scwx::qt::view::level3_product_view] "; +static const std::string logPrefix_ = "scwx::qt::view::level3_product_view"; static constexpr uint16_t RANGE_FOLDED = 1u; diff --git a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp index 86336ab8..560319f6 100644 --- a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp @@ -1,11 +1,11 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -16,7 +16,8 @@ namespace qt namespace view { -static const std::string logPrefix_ = "[scwx::qt::view::level3_radial_view] "; +static const std::string logPrefix_ = "scwx::qt::view::level3_radial_view"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static constexpr uint16_t RANGE_FOLDED = 1u; static constexpr uint32_t VERTICES_PER_BIN = 6u; @@ -105,7 +106,7 @@ void Level3RadialView::SelectTime(std::chrono::system_clock::time_point time) void Level3RadialView::ComputeSweep() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ComputeSweep()"; + logger_->debug("ComputeSweep()"); boost::timer::cpu_timer timer; @@ -120,8 +121,7 @@ void Level3RadialView::ComputeSweep() std::dynamic_pointer_cast(message); if (gpm == nullptr) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Graphic Product Message not found"; + logger_->warn("Graphic Product Message not found"); return; } else if (gpm == graphic_product_message()) @@ -139,7 +139,7 @@ void Level3RadialView::ComputeSweep() gpm->symbology_block(); if (descriptionBlock == nullptr || symbologyBlock == nullptr) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Missing blocks"; + logger_->warn("Missing blocks"); return; } @@ -147,8 +147,7 @@ void Level3RadialView::ComputeSweep() uint16_t numberOfLayers = symbologyBlock->number_of_layers(); if (numberOfLayers < 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "No layers present in symbology block"; + logger_->warn("No layers present in symbology block"); return; } @@ -199,7 +198,7 @@ void Level3RadialView::ComputeSweep() } else { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "No radial data found"; + logger_->debug("No radial data found"); return; } @@ -207,8 +206,7 @@ void Level3RadialView::ComputeSweep() const size_t radials = radialData->number_of_radials(); if (radials != 360 && radials != 720) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Unsupported number of radials: " << radials; + logger_->warn("Unsupported number of radials: {}", radials); return; } @@ -223,8 +221,7 @@ void Level3RadialView::ComputeSweep() const uint16_t gates = radialData->number_of_range_bins(); if (gates < 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "No range bins in radial data"; + logger_->warn("No range bins in radial data"); return; } @@ -368,8 +365,7 @@ void Level3RadialView::ComputeSweep() dataMoments8.shrink_to_fit(); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Vertices calculated in " << timer.format(6, "%ws"); + logger_->debug("Vertices calculated in {}", timer.format(6, "%ws")); UpdateColorTable(); diff --git a/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp b/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp index 3bf9605d..9494ee19 100644 --- a/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_raster_view.cpp @@ -1,10 +1,10 @@ #include #include +#include #include #include #include -#include #include #include #include @@ -16,7 +16,8 @@ namespace qt namespace view { -static const std::string logPrefix_ = "[scwx::qt::view::level3_raster_view] "; +static const std::string logPrefix_ = "scwx::qt::view::level3_raster_view"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static constexpr uint16_t RANGE_FOLDED = 1u; static constexpr uint32_t VERTICES_PER_BIN = 6u; @@ -105,7 +106,7 @@ void Level3RasterView::SelectTime(std::chrono::system_clock::time_point time) void Level3RasterView::ComputeSweep() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ComputeSweep()"; + logger_->debug("ComputeSweep()"); boost::timer::cpu_timer timer; @@ -120,8 +121,7 @@ void Level3RasterView::ComputeSweep() std::dynamic_pointer_cast(message); if (gpm == nullptr) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Graphic Product Message not found"; + logger_->warn("Graphic Product Message not found"); return; } else if (gpm == graphic_product_message()) @@ -139,7 +139,7 @@ void Level3RasterView::ComputeSweep() gpm->symbology_block(); if (descriptionBlock == nullptr || symbologyBlock == nullptr) { - BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Missing blocks"; + logger_->warn("Missing blocks"); return; } @@ -147,8 +147,7 @@ void Level3RasterView::ComputeSweep() uint16_t numberOfLayers = symbologyBlock->number_of_layers(); if (numberOfLayers < 1) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "No layers present in symbology block"; + logger_->warn("No layers present in symbology block"); return; } @@ -179,7 +178,7 @@ void Level3RasterView::ComputeSweep() if (rasterData == nullptr) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "No raster data found"; + logger_->debug("No raster data found"); return; } @@ -193,7 +192,7 @@ void Level3RasterView::ComputeSweep() if (maxColumns == 0) { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "No raster bins found"; + logger_->debug("No raster bins found"); return; } @@ -256,8 +255,7 @@ void Level3RasterView::ComputeSweep() }); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Coordinates calculated in " << timer.format(6, "%ws"); + logger_->debug("Coordinates calculated in {}", timer.format(6, "%ws")); // Calculate vertices timer.start(); @@ -332,8 +330,7 @@ void Level3RasterView::ComputeSweep() dataMoments8.shrink_to_fit(); timer.stop(); - BOOST_LOG_TRIVIAL(debug) - << logPrefix_ << "Vertices calculated in " << timer.format(6, "%ws"); + logger_->debug("Vertices calculated in {}", timer.format(6, "%ws")); UpdateColorTable(); diff --git a/scwx-qt/source/scwx/qt/view/radar_product_view.cpp b/scwx-qt/source/scwx/qt/view/radar_product_view.cpp index 73ce6789..33771694 100644 --- a/scwx-qt/source/scwx/qt/view/radar_product_view.cpp +++ b/scwx-qt/source/scwx/qt/view/radar_product_view.cpp @@ -1,7 +1,7 @@ #include #include +#include -#include #include #include @@ -12,7 +12,8 @@ namespace qt namespace view { -static const std::string logPrefix_ = "[scwx::qt::view::radar_product_view] "; +static const std::string logPrefix_ = "scwx::qt::view::radar_product_view"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); static const std::vector DEFAULT_COLOR_TABLE = { boost::gil::rgba8_pixel_t(0, 128, 0, 255), @@ -102,7 +103,7 @@ RadarProductView::GetCfpMomentData() const void RadarProductView::ComputeSweep() { - BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ComputeSweep()"; + logger_->debug("ComputeSweep()"); emit SweepComputed(); } diff --git a/scwx-qt/source/scwx/qt/view/radar_product_view_factory.cpp b/scwx-qt/source/scwx/qt/view/radar_product_view_factory.cpp index a188ddbb..0ee67825 100644 --- a/scwx-qt/source/scwx/qt/view/radar_product_view_factory.cpp +++ b/scwx-qt/source/scwx/qt/view/radar_product_view_factory.cpp @@ -2,11 +2,10 @@ #include #include #include +#include #include -#include - namespace scwx { namespace qt @@ -15,7 +14,8 @@ namespace view { static const std::string logPrefix_ = - "[scwx::qt::view::radar_product_view_factory] "; + "scwx::qt::view::radar_product_view_factory"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); typedef std::function( const std::string& productName, @@ -46,8 +46,7 @@ std::shared_ptr RadarProductViewFactory::Create( if (product == common::Level2Product::Unknown) { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Unknown Level 2 radar product: " << productName; + logger_->warn("Unknown Level 2 radar product: {}", productName); } else { @@ -67,9 +66,8 @@ std::shared_ptr RadarProductViewFactory::Create( } else { - BOOST_LOG_TRIVIAL(warning) - << logPrefix_ << "Unknown radar product group: " - << common::GetRadarProductGroupName(productGroup); + logger_->warn("Unknown radar product group: {}", + common::GetRadarProductGroupName(productGroup)); } return view; From 7734fcababaf5b4b139059c2b13f730ca7035928 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 19 Apr 2022 16:05:31 -0500 Subject: [PATCH 10/13] Boost.Log -> spdlog - test --- test/source/scwx/awips/coded_location.test.cpp | 4 +--- .../scwx/awips/coded_time_motion_location.test.cpp | 4 +--- test/source/scwx/awips/pvtec.test.cpp | 4 +--- test/source/scwx/awips/text_product_file.test.cpp | 4 +--- test/source/scwx/wsr88d/nexrad_file_factory.test.cpp | 5 +---- test/source/scwx/wxtest.cpp | 10 +++++----- 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/test/source/scwx/awips/coded_location.test.cpp b/test/source/scwx/awips/coded_location.test.cpp index 3666ae29..fa387a87 100644 --- a/test/source/scwx/awips/coded_location.test.cpp +++ b/test/source/scwx/awips/coded_location.test.cpp @@ -2,14 +2,12 @@ #include -#include - namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::coded_location.test] "; +static const std::string logPrefix_ = "scwx::awips::coded_location.test"; TEST(CodedLocation, WFO100W) { diff --git a/test/source/scwx/awips/coded_time_motion_location.test.cpp b/test/source/scwx/awips/coded_time_motion_location.test.cpp index b533c714..b0ed1fd5 100644 --- a/test/source/scwx/awips/coded_time_motion_location.test.cpp +++ b/test/source/scwx/awips/coded_time_motion_location.test.cpp @@ -2,15 +2,13 @@ #include -#include - namespace scwx { namespace awips { static const std::string logPrefix_ = - "[scwx::awips::coded_time_motion_location.test] "; + "scwx::awips::coded_time_motion_location.test"; TEST(CodedTimeMotionLocation, LeadingZeroes) { diff --git a/test/source/scwx/awips/pvtec.test.cpp b/test/source/scwx/awips/pvtec.test.cpp index 23b21b7b..b92880de 100644 --- a/test/source/scwx/awips/pvtec.test.cpp +++ b/test/source/scwx/awips/pvtec.test.cpp @@ -2,14 +2,12 @@ #include -#include - namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::pvtec.test] "; +static const std::string logPrefix_ = "scwx::awips::pvtec.test"; std::pair> diff --git a/test/source/scwx/awips/text_product_file.test.cpp b/test/source/scwx/awips/text_product_file.test.cpp index 251a1c01..fa335746 100644 --- a/test/source/scwx/awips/text_product_file.test.cpp +++ b/test/source/scwx/awips/text_product_file.test.cpp @@ -2,14 +2,12 @@ #include -#include - namespace scwx { namespace awips { -static const std::string logPrefix_ = "[scwx::awips::text_product_file.test] "; +static const std::string logPrefix_ = "scwx::awips::text_product_file.test"; class TextProductValidFileTest : public testing::TestWithParam { diff --git a/test/source/scwx/wsr88d/nexrad_file_factory.test.cpp b/test/source/scwx/wsr88d/nexrad_file_factory.test.cpp index 5f1b0bbf..6feb2085 100644 --- a/test/source/scwx/wsr88d/nexrad_file_factory.test.cpp +++ b/test/source/scwx/wsr88d/nexrad_file_factory.test.cpp @@ -4,15 +4,12 @@ #include -#include - namespace scwx { namespace wsr88d { -static const std::string logPrefix_ = - "[scwx::wsr88d::nexrad_file_factory.test] "; +static const std::string logPrefix_ = "scwx::wsr88d::nexrad_file_factory.test"; TEST(NexradFileFactory, Level2V06) { diff --git a/test/source/scwx/wxtest.cpp b/test/source/scwx/wxtest.cpp index 3bb34268..e3d26c74 100644 --- a/test/source/scwx/wxtest.cpp +++ b/test/source/scwx/wxtest.cpp @@ -1,12 +1,12 @@ -#include +#include -#include -#include +#include +#include int main(int argc, char** argv) { - boost::log::core::get()->set_filter(boost::log::trivial::severity >= - boost::log::trivial::debug); + scwx::util::Logger::Initialize(); + spdlog::set_level(spdlog::level::debug); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); From 034b4f78c55685adaa20ba0ac5f4f92384b45cdc Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 19 Apr 2022 16:05:46 -0500 Subject: [PATCH 11/13] Removing Boost.Log from main --- scwx-qt/source/scwx/qt/main/main.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scwx-qt/source/scwx/qt/main/main.cpp b/scwx-qt/source/scwx/qt/main/main.cpp index 0bb745b8..f4c782d9 100644 --- a/scwx-qt/source/scwx/qt/main/main.cpp +++ b/scwx-qt/source/scwx/qt/main/main.cpp @@ -4,16 +4,11 @@ #include #include -#include -#include #include #include int main(int argc, char* argv[]) { - boost::log::core::get()->set_filter(boost::log::trivial::severity >= - boost::log::trivial::debug); - scwx::util::Logger::Initialize(); spdlog::set_level(spdlog::level::debug); From a90d95cf6d37aad8fa00b558906e43edfb737acc Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 19 Apr 2022 16:06:01 -0500 Subject: [PATCH 12/13] Revert "Workaround for Boost 1.78.0 log namespace change" This reverts commit ae886fd624af1010b37c61697362318a8baf6758. --- scwx-qt/scwx-qt.cmake | 4 ---- test/test.cmake | 5 ----- wxdata/wxdata.cmake | 3 --- 3 files changed, 12 deletions(-) diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index f1759304..a8f7911e 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -206,10 +206,6 @@ qt6_create_translation_scwx(QM_FILES ${scwx-qt_SOURCE_DIR} ${TS_FILES}) if (WIN32) target_compile_definitions(scwx-qt PUBLIC WIN32_LEAN_AND_MEAN) target_compile_definitions(supercell-wx PUBLIC WIN32_LEAN_AND_MEAN) - - # For Boost::log - target_compile_definitions(scwx-qt PRIVATE BOOST_USE_WINAPI_VERSION=0x0601) - target_compile_definitions(supercell-wx PRIVATE BOOST_USE_WINAPI_VERSION=0x0601) endif() target_include_directories(scwx-qt PUBLIC ${scwx-qt_SOURCE_DIR}/source diff --git a/test/test.cmake b/test/test.cmake index 9525a4e6..2820dc09 100644 --- a/test/test.cmake +++ b/test/test.cmake @@ -54,11 +54,6 @@ endif() target_compile_definitions(wxtest PRIVATE SCWX_TEST_DATA_DIR="${SCWX_DIR}/test/data") -if (WIN32) - # For Boost::log - target_compile_definitions(wxtest PRIVATE BOOST_USE_WINAPI_VERSION=0x0601) -endif() - gtest_discover_tests(wxtest) target_link_libraries(wxtest GTest::gtest diff --git a/wxdata/wxdata.cmake b/wxdata/wxdata.cmake index ec82c5b6..7c253c2f 100644 --- a/wxdata/wxdata.cmake +++ b/wxdata/wxdata.cmake @@ -202,9 +202,6 @@ target_link_libraries(wxdata INTERFACE Boost::iostreams if (WIN32) target_link_libraries(wxdata INTERFACE Ws2_32) - - # For Boost::log - target_compile_definitions(wxdata PRIVATE BOOST_USE_WINAPI_VERSION=0x0601) endif() set_target_properties(wxdata PROPERTIES CXX_STANDARD 20 From cc9be6bdd0727d8b8037665f40479f2b5a98e99a Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 19 Apr 2022 16:09:13 -0500 Subject: [PATCH 13/13] Remove Boost::log dependency --- wxdata/wxdata.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/wxdata/wxdata.cmake b/wxdata/wxdata.cmake index 7c253c2f..a66672d4 100644 --- a/wxdata/wxdata.cmake +++ b/wxdata/wxdata.cmake @@ -196,7 +196,6 @@ endif() target_link_libraries(wxdata PUBLIC spdlog::spdlog) target_link_libraries(wxdata INTERFACE Boost::iostreams - Boost::log BZip2::BZip2 hsluv-c)