customize boost trivial logger
This commit is contained in:
parent
2514cdd2f1
commit
6f7808c3d4
|
@ -8,7 +8,7 @@ set(Boost_USE_MULTITHREADED ON)
|
||||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Users/Public/Libraries/boost_1_84_0")
|
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Users/Public/Libraries/boost_1_84_0")
|
||||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/Users/Public/Libraries/boost_1_84_0/stage/lib")
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/Users/Public/Libraries/boost_1_84_0/stage/lib")
|
||||||
|
|
||||||
find_package(Boost 1.78.0 REQUIRED COMPONENTS filesystem json)
|
find_package(Boost 1.78.0 REQUIRED COMPONENTS filesystem json log)
|
||||||
if (Boost_FOUND)
|
if (Boost_FOUND)
|
||||||
include_directories(${Boost_INCLUDE_DIR})
|
include_directories(${Boost_INCLUDE_DIR})
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -41,4 +41,9 @@ add_executable(hello_async
|
||||||
src/Logger.h
|
src/Logger.h
|
||||||
src/Logger.cpp)
|
src/Logger.cpp)
|
||||||
target_include_directories(hello_async PUBLIC ${Boost_INCLUDE_DIR})
|
target_include_directories(hello_async PUBLIC ${Boost_INCLUDE_DIR})
|
||||||
target_link_libraries(hello_async PRIVATE Threads::Threads Boost::filesystem Boost::json)
|
target_link_libraries(hello_async PRIVATE
|
||||||
|
Threads::Threads
|
||||||
|
Boost::filesystem
|
||||||
|
Boost::json
|
||||||
|
Boost::log
|
||||||
|
)
|
||||||
|
|
14
main.cpp
14
main.cpp
|
@ -2,6 +2,10 @@
|
||||||
//
|
//
|
||||||
#include <boost/json.hpp>
|
#include <boost/json.hpp>
|
||||||
#include <boost/json/src.hpp>
|
#include <boost/json/src.hpp>
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
#include <boost/log/core.hpp>
|
||||||
|
#include <boost/log/expressions.hpp>
|
||||||
|
#include <boost/log/utility/setup/file.hpp>
|
||||||
#include <boost/asio/signal_set.hpp>
|
#include <boost/asio/signal_set.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -92,8 +96,14 @@ void RunWorkers(unsigned n, const Fn& fn)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Logger::GetInstance().SetOutStream(cout);
|
boost::log::add_file_log("./Logs.txt"s);
|
||||||
Logger::GetInstance().Log("Server started");
|
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "Message level trace"sv;
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "Message level debug"sv;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Message level info"sv;
|
||||||
|
BOOST_LOG_TRIVIAL(warning) << "Message level warning"sv;
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Message level error"sv;
|
||||||
|
BOOST_LOG_TRIVIAL(fatal) << "Message level fatal"sv;
|
||||||
|
|
||||||
const unsigned num_threads = std::thread::hardware_concurrency();
|
const unsigned num_threads = std::thread::hardware_concurrency();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user