diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/GpgFrontendTest.cpp | 46 | ||||
-rw-r--r-- | src/test/GpgFrontendTest.h | 17 |
2 files changed, 13 insertions, 50 deletions
diff --git a/src/test/GpgFrontendTest.cpp b/src/test/GpgFrontendTest.cpp index 29903c39..f030ed12 100644 --- a/src/test/GpgFrontendTest.cpp +++ b/src/test/GpgFrontendTest.cpp @@ -29,8 +29,6 @@ #include "GpgFrontendTest.h" #include <gtest/gtest.h> -#include <spdlog/sinks/rotating_file_sink.h> -#include <spdlog/sinks/stdout_color_sinks.h> #include <boost/date_time.hpp> #include <boost/dll.hpp> @@ -46,42 +44,6 @@ namespace GpgFrontend::Test { -void InitTestLoggingSystem(spdlog::level::level_enum level) { - // get the log directory - auto logfile_path = - (GlobalSettingStation::GetInstance().GetLogDir() / "test"); - logfile_path.replace_extension(".log"); - - // sinks - std::vector<spdlog::sink_ptr> sinks; - sinks.push_back( - SecureCreateSharedObject<spdlog::sinks::stderr_color_sink_mt>()); - sinks.push_back( - SecureCreateSharedObject<spdlog::sinks::rotating_file_sink_mt>( - logfile_path.u8string(), 1048576 * 32, 8)); - - // logger - auto test_logger = SecureCreateSharedObject<spdlog::logger>( - "test", begin(sinks), end(sinks)); - test_logger->set_pattern( - "[%H:%M:%S.%e] [T:%t] [%=6n] %^[%=8l]%$ [%s:%#] [%!] -> %v (+%ius)"); - - // set the level of logger - test_logger->set_level(level); - - // register it as default logger - spdlog::set_default_logger(test_logger); -} - -void ShutdownTestLoggingSystem() { -#ifdef WINDOWS - // Under VisualStudio, this must be called before main finishes to workaround - // a known VS issue - spdlog::drop_all(); - spdlog::shutdown(); -#endif -} - auto GenerateRandomString(size_t length) -> std::string { const std::string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -100,8 +62,8 @@ auto GenerateRandomString(size_t length) -> std::string { void ConfigureGpgContext() { auto db_path = std::filesystem::temp_directory_path() / GenerateRandomString(12); - SPDLOG_DEBUG("setting up new database path for test case: {}", - db_path.string()); + GF_TEST_LOG_DEBUG("setting up new database path for test case: {}", + db_path.string()); if (!std::filesystem::exists(db_path)) { std::filesystem::create_directory(db_path); @@ -146,8 +108,8 @@ void SetupGlobalTestEnv() { auto test_config_path = test_path / "conf" / "test.cfg"; auto test_data_path = test_path / "data"; - SPDLOG_INFO("test config file path: {}", test_config_path.string()); - SPDLOG_INFO("test data file path: {}", test_data_path.string()); + GF_TEST_LOG_INFO("test config file path: {}", test_config_path.string()); + GF_TEST_LOG_INFO("test data file path: {}", test_data_path.string()); libconfig::Config cfg; ASSERT_NO_THROW(cfg.readFile(test_config_path.c_str())); diff --git a/src/test/GpgFrontendTest.h b/src/test/GpgFrontendTest.h index 897a8a05..405eee90 100644 --- a/src/test/GpgFrontendTest.h +++ b/src/test/GpgFrontendTest.h @@ -28,23 +28,24 @@ #pragma once -#include <spdlog/spdlog.h> - #include "GpgFrontendTestExport.h" +// Core +#include "core/utils/LogUtils.h" + namespace GpgFrontend::Test { struct GpgFrontendContext { int argc; char **argv; - spdlog::level::level_enum log_level; }; -void GPGFRONTEND_TEST_EXPORT -InitTestLoggingSystem(spdlog::level::level_enum level); - -void GPGFRONTEND_TEST_EXPORT ShutdownTestLoggingSystem(); - auto GPGFRONTEND_TEST_EXPORT ExecuteAllTestCase(GpgFrontendContext args) -> int; +#define GF_TEST_LOG_TRACE(...) GF_LOG_TRACE("test", __VA_ARGS__) +#define GF_TEST_LOG_DEBUG(...) GF_LOG_DEBUG("test", __VA_ARGS__) +#define GF_TEST_LOG_INFO(...) GF_LOG_INFO("test", __VA_ARGS__) +#define GF_TEST_LOG_WARN(...) GF_LOG_WARN("test", __VA_ARGS__) +#define GF_TEST_LOG_ERROR(...) GF_LOG_ERROR("test", __VA_ARGS__) + } // namespace GpgFrontend::Test |