mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:40:04 +00:00 
			
		
		
		
	Initial setup for spdlog
This commit is contained in:
		
							parent
							
								
									7aef98b002
								
							
						
					
					
						commit
						20b8c75234
					
				
					 5 changed files with 67 additions and 0 deletions
				
			
		|  | @ -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 | ||||||
|  |  | ||||||
|  | @ -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(); | ||||||
|  |  | ||||||
							
								
								
									
										20
									
								
								wxdata/include/scwx/util/logger.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								wxdata/include/scwx/util/logger.hpp
									
										
									
									
									
										Normal 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
 | ||||||
							
								
								
									
										37
									
								
								wxdata/source/scwx/util/logger.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								wxdata/source/scwx/util/logger.cpp
									
										
									
									
									
										Normal 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
 | ||||||
|  | @ -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 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat