Boost.Log -> spdlog - awips and common

This commit is contained in:
Dan Paulat 2022-04-16 07:48:49 -05:00
parent 3d162f0336
commit 44bcc7dd4c
10 changed files with 82 additions and 103 deletions

View file

@ -1,15 +1,15 @@
#include <scwx/awips/coded_location.hpp>
#include <scwx/util/logger.hpp>
#include <sstream>
#include <boost/log/trivial.hpp>
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);
}
}