mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:40:05 +00:00
Removing boost log from Boost.Log -> spdlog - settings, types, util, view
This commit is contained in:
parent
e6bddc79db
commit
c6281d799f
13 changed files with 109 additions and 127 deletions
|
|
@ -2,11 +2,11 @@
|
|||
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
|
||||
|
||||
#include <scwx/qt/util/font.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <codecvt>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
|
@ -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<FontBuffer> buffer,
|
|||
auto it = p->glyphs_.find(c);
|
||||
if (it == p->glyphs_.end())
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info)
|
||||
<< logPrefix_
|
||||
<< "Could not draw character: " << static_cast<uint32_t>(c);
|
||||
logger_->info("Could not draw character: {}",
|
||||
static_cast<uint32_t>(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<uint32_t>(c);
|
||||
logger_->info("Character not found: {}", static_cast<uint32_t>(c));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +240,7 @@ GLuint Font::GenerateTexture(gl::OpenGLFunctions& gl)
|
|||
|
||||
std::shared_ptr<Font> 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> font = nullptr;
|
||||
boost::timer::cpu_timer timer;
|
||||
|
|
@ -250,7 +248,7 @@ std::shared_ptr<Font> 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> 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> 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)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
#include <scwx/qt/util/font_buffer.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
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<GLuint> 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <scwx/qt/util/json.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue