Initial setup for spdlog

This commit is contained in:
Dan Paulat 2022-04-13 20:08:04 -05:00
parent 7aef98b002
commit 20b8c75234
5 changed files with 67 additions and 0 deletions

View file

@ -19,6 +19,7 @@ conan_cmake_configure(REQUIRES boost/1.78.0
glm/0.9.9.8 glm/0.9.9.8
gtest/cci.20210126 gtest/cci.20210126
openssl/1.1.1n openssl/1.1.1n
spdlog/1.10.0
vulkan-loader/1.3.204.1 vulkan-loader/1.3.204.1
GENERATORS cmake GENERATORS cmake
cmake_find_package cmake_find_package

View file

@ -2,9 +2,11 @@
#include <scwx/qt/main/main_window.hpp> #include <scwx/qt/main/main_window.hpp>
#include <scwx/qt/manager/resource_manager.hpp> #include <scwx/qt/manager/resource_manager.hpp>
#include <scwx/qt/manager/settings_manager.hpp> #include <scwx/qt/manager/settings_manager.hpp>
#include <scwx/util/logger.hpp>
#include <boost/log/expressions.hpp> #include <boost/log/expressions.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
#include <spdlog/spdlog.h>
#include <QApplication> #include <QApplication>
int main(int argc, char* argv[]) 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::core::get()->set_filter(boost::log::trivial::severity >=
boost::log::trivial::debug); boost::log::trivial::debug);
scwx::util::Logger::Initialize();
spdlog::set_level(spdlog::level::debug);
QCoreApplication::setApplicationName("Supercell Wx"); QCoreApplication::setApplicationName("Supercell Wx");
scwx::qt::config::RadarSite::Initialize(); scwx::qt::config::RadarSite::Initialize();

View file

@ -0,0 +1,20 @@
#pragma once
#include <memory>
#include <string>
#include <spdlog/logger.h>
namespace scwx
{
namespace util
{
namespace Logger
{
void Initialize();
std::shared_ptr<spdlog::logger> Create(const std::string& name);
} // namespace Logger
} // namespace util
} // namespace scwx

View file

@ -0,0 +1,37 @@
#include <scwx/util/logger.hpp>
#include <mutex>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
namespace scwx
{
namespace util
{
namespace Logger
{
void Initialize()
{
spdlog::set_pattern("[%Y-%m-%d %T.%e] [%t] [%^%l%$] [%n] %v");
}
std::shared_ptr<spdlog::logger> Create(const std::string& name)
{
// Create a shared sink
static auto sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
// Create the logger
std::shared_ptr<spdlog::logger> logger =
std::make_shared<spdlog::logger>(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

View file

@ -1,6 +1,7 @@
project(scwx-data) project(scwx-data)
find_package(Boost) find_package(Boost)
find_package(spdlog)
set(HDR_AWIPS include/scwx/awips/coded_location.hpp set(HDR_AWIPS include/scwx/awips/coded_location.hpp
include/scwx/awips/coded_time_motion_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) source/scwx/common/vcp.cpp)
set(HDR_UTIL include/scwx/util/float.hpp set(HDR_UTIL include/scwx/util/float.hpp
include/scwx/util/iterator.hpp include/scwx/util/iterator.hpp
include/scwx/util/logger.hpp
include/scwx/util/rangebuf.hpp include/scwx/util/rangebuf.hpp
include/scwx/util/streams.hpp include/scwx/util/streams.hpp
include/scwx/util/threads.hpp include/scwx/util/threads.hpp
include/scwx/util/time.hpp include/scwx/util/time.hpp
include/scwx/util/vectorbuf.hpp) include/scwx/util/vectorbuf.hpp)
set(SRC_UTIL source/scwx/util/float.cpp set(SRC_UTIL source/scwx/util/float.cpp
source/scwx/util/logger.cpp
source/scwx/util/rangebuf.cpp source/scwx/util/rangebuf.cpp
source/scwx/util/streams.cpp source/scwx/util/streams.cpp
source/scwx/util/time.cpp source/scwx/util/time.cpp
@ -191,6 +194,7 @@ if(MSVC)
target_compile_options(wxdata PRIVATE /W3) target_compile_options(wxdata PRIVATE /W3)
endif() endif()
target_link_libraries(wxdata PUBLIC spdlog::spdlog)
target_link_libraries(wxdata INTERFACE Boost::iostreams target_link_libraries(wxdata INTERFACE Boost::iostreams
Boost::log Boost::log
BZip2::BZip2 BZip2::BZip2