Fixed spdlog loglevel initialization
This commit is contained in:
parent
7856046951
commit
f36b544b11
2 changed files with 24 additions and 0 deletions
|
@ -22,6 +22,7 @@ set(BOOST_INCLUDE_LIBRARIES "pfr;asio;serialization")
|
||||||
option(CPM_USE_LOCAL_PACKAGES "Use local packages" ON)
|
option(CPM_USE_LOCAL_PACKAGES "Use local packages" ON)
|
||||||
option(UTEMPL_USE_LOCAL_PACKAGE "Use utempl local package" OFF)
|
option(UTEMPL_USE_LOCAL_PACKAGE "Use utempl local package" OFF)
|
||||||
option(BUILD_EXECUTABLE ON)
|
option(BUILD_EXECUTABLE ON)
|
||||||
|
option(LOG_LEVEL 0 "Available log levels: 0=TRACE, 1=DEBUG,2= INFO,3= WARN, 4=ERROR, 5=CRITICAL, 6=OFF") # Compile program with highest available log levle to trace everything
|
||||||
set(UTEMPL_URL
|
set(UTEMPL_URL
|
||||||
"https://sha512sum.xyz/git/sha512sum/utempl"
|
"https://sha512sum.xyz/git/sha512sum/utempl"
|
||||||
CACHE STRING "utempl repository URL")
|
CACHE STRING "utempl repository URL")
|
||||||
|
@ -259,6 +260,7 @@ if(ENABLE_TESTS)
|
||||||
target_sources(larra_xmpp_tests PUBLIC ${SOURCES})
|
target_sources(larra_xmpp_tests PUBLIC ${SOURCES})
|
||||||
target_link_libraries(larra_xmpp_tests GTest::gtest_main
|
target_link_libraries(larra_xmpp_tests GTest::gtest_main
|
||||||
larra_xmpp)
|
larra_xmpp)
|
||||||
|
target_compile_definitions(larra_xmpp_tests PRIVATE SPDLOG_ACTIVE_LEVEL=0) # SPDLOG_LEVEL_TRACE=0. Check LOG_LEVEL variable and spdlog documentation for more details
|
||||||
set_property(TARGET larra_xmpp_tests PROPERTY CXX_STANDARD 23)
|
set_property(TARGET larra_xmpp_tests PROPERTY CXX_STANDARD 23)
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(larra_xmpp_tests)
|
gtest_discover_tests(larra_xmpp_tests)
|
||||||
|
@ -270,6 +272,7 @@ if(ENABLE_EXAMPLES)
|
||||||
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SRC} NAME_WE)
|
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SRC} NAME_WE)
|
||||||
add_executable(${EXAMPLE_NAME} ${EXAMPLE_SRC})
|
add_executable(${EXAMPLE_NAME} ${EXAMPLE_SRC})
|
||||||
target_link_libraries(${EXAMPLE_NAME} larra_xmpp)
|
target_link_libraries(${EXAMPLE_NAME} larra_xmpp)
|
||||||
|
target_compile_definitions(${EXAMPLE_NAME} PRIVATE SPDLOG_ACTIVE_LEVEL=${LOG_LEVEL})
|
||||||
set_property(TARGET ${EXAMPLE_NAME} PROPERTY CXX_STANDARD 23)
|
set_property(TARGET ${EXAMPLE_NAME} PROPERTY CXX_STANDARD 23)
|
||||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES
|
set_target_properties(${EXAMPLE_NAME} PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples/output")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples/output")
|
||||||
|
|
21
tests/main.cpp
Normal file
21
tests/main.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <print>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
class PreconfigureEnvironment : public ::testing::Environment {
|
||||||
|
public:
|
||||||
|
void SetUp() override {
|
||||||
|
spdlog::set_level(spdlog::level::trace);
|
||||||
|
std::println("\nPreconfigureEnvironment setup:\n\tCompiled max availabel log level: {}\n\tCurrently set log level: {}",
|
||||||
|
SPDLOG_ACTIVE_LEVEL,
|
||||||
|
std::to_underlying(spdlog::get_level()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto main(int argc, char** argv) -> int {
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
::testing::AddGlobalTestEnvironment(new PreconfigureEnvironment); // NOLINT GTest takes ownership
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
Loading…
Reference in a new issue