generated from Sithas/conan_template
Подготовка интеграционного теста
This commit is contained in:
+10
-2
@@ -13,7 +13,7 @@ set(Boost_USE_MULTITHREADED ON)
|
|||||||
set(Boost_INCLUDE_DIR ${BOOST_ROOT})
|
set(Boost_INCLUDE_DIR ${BOOST_ROOT})
|
||||||
set(Boost_LIBRARY_DIR "${BOOST_ROOT}/stage/lib")
|
set(Boost_LIBRARY_DIR "${BOOST_ROOT}/stage/lib")
|
||||||
|
|
||||||
find_package(Boost 1.88.0 REQUIRED COMPONENTS filesystem json log)
|
find_package(Boost 1.88.0 REQUIRED COMPONENTS filesystem json log system filesystem)
|
||||||
if (Boost_FOUND)
|
if (Boost_FOUND)
|
||||||
include_directories(${Boost_INCLUDE_DIR})
|
include_directories(${Boost_INCLUDE_DIR})
|
||||||
endif ()
|
endif ()
|
||||||
@@ -50,9 +50,17 @@ add_executable(App ./src/main.cpp
|
|||||||
./src/endpoints_handlers/AuthLogoutExecutor.h
|
./src/endpoints_handlers/AuthLogoutExecutor.h
|
||||||
./src/exceptions/session_exception.cpp
|
./src/exceptions/session_exception.cpp
|
||||||
./src/exceptions/session_exception.h
|
./src/exceptions/session_exception.h
|
||||||
|
src/log/Log.h
|
||||||
|
src/log/Log.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(App PRIVATE Boost::boost Boost::json Threads::Threads mysql::concpp)
|
target_link_libraries(App PRIVATE Boost::boost
|
||||||
|
Boost::json
|
||||||
|
Boost::log
|
||||||
|
Boost::system
|
||||||
|
Boost::filesystem
|
||||||
|
Threads::Threads
|
||||||
|
mysql::concpp)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
#include <boost/log/utility/setup/file.hpp>
|
||||||
|
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||||
|
|
||||||
|
namespace logging = boost::log;
|
||||||
|
|
||||||
|
namespace uad
|
||||||
|
{
|
||||||
|
void InitLogs()
|
||||||
|
{
|
||||||
|
logging::add_file_log(
|
||||||
|
logging::keywords::file_name = "app_%Y-%m-%d_%H-%M-%S.log", // Имя файла с timestamp
|
||||||
|
logging::keywords::rotation_size = 10 * 1024 * 1024, // Ротация при достижении 10 МБ
|
||||||
|
logging::keywords::time_based_rotation =
|
||||||
|
logging::sinks::file::rotation_at_time_point(0, 0, 0), // Ротация каждый день в полночь
|
||||||
|
logging::keywords::format = "[%TimeStamp%] [%Severity%]: %Message%" // Формат записи
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace uad
|
||||||
|
{
|
||||||
|
void InitLogs();
|
||||||
|
}
|
||||||
@@ -14,11 +14,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
#include <boost/log/utility/setup/file.hpp>
|
||||||
|
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||||
|
|
||||||
#include "./session/WebsocketSession.h"
|
#include "./session/WebsocketSession.h"
|
||||||
#include "./listener/Listener.h"
|
#include "./listener/Listener.h"
|
||||||
#include "./db/mysql_connector.h"
|
#include "./db/mysql_connector.h"
|
||||||
#include "entities/user.h"
|
#include "entities/user.h"
|
||||||
|
#include "log/Log.h"
|
||||||
|
|
||||||
namespace beast = boost::beast;
|
namespace beast = boost::beast;
|
||||||
namespace http = beast::http;
|
namespace http = beast::http;
|
||||||
@@ -28,6 +32,7 @@ using tcp = boost::asio::ip::tcp;
|
|||||||
using namespace uad;
|
using namespace uad;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
namespace logging = boost::log;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
@@ -44,6 +49,11 @@ int main(int argc, char* argv[])
|
|||||||
auto const threads = std::max<int>(1, std::atoi(argv[4]));
|
auto const threads = std::max<int>(1, std::atoi(argv[4]));
|
||||||
string mysql_credentials = argv[5];
|
string mysql_credentials = argv[5];
|
||||||
|
|
||||||
|
InitLogs();
|
||||||
|
|
||||||
|
// Добавление общих атрибутов (включая время)
|
||||||
|
logging::add_common_attributes();
|
||||||
|
|
||||||
uad::SetMySqlSession(new mysqlx::Session(mysql_credentials));
|
uad::SetMySqlSession(new mysqlx::Session(mysql_credentials));
|
||||||
|
|
||||||
net::io_context ioc{threads};
|
net::io_context ioc{threads};
|
||||||
@@ -53,6 +63,8 @@ int main(int argc, char* argv[])
|
|||||||
net::signal_set signals(ioc, SIGINT, SIGTERM);
|
net::signal_set signals(ioc, SIGINT, SIGTERM);
|
||||||
signals.async_wait([&](beast::error_code const&, int) { ioc.stop(); });
|
signals.async_wait([&](beast::error_code const&, int) { ioc.stop(); });
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Приложение запущено";
|
||||||
|
|
||||||
std::vector<std::thread> v;
|
std::vector<std::thread> v;
|
||||||
v.reserve(threads - 1);
|
v.reserve(threads - 1);
|
||||||
for (auto i = threads - 1; i > 0; --i)
|
for (auto i = threads - 1; i > 0; --i)
|
||||||
|
|||||||
Reference in New Issue
Block a user