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;