From e6bddc79dbc0f40501d6d82121d6e19e6ac083a1 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Mon, 18 Apr 2022 09:09:02 -0500 Subject: [PATCH] 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")) {