Adding a general logger and integrating it with daggyr
This commit is contained in:
@@ -11,6 +11,7 @@ add_executable(${PROJECT_NAME} main.cpp
|
||||
unit_serialization.cpp
|
||||
unit_threadpool.cpp
|
||||
unit_utilities.cpp
|
||||
unit_generallogger.cpp
|
||||
# integration tests
|
||||
int_basic.cpp
|
||||
# Performance checks
|
||||
|
||||
31
libdaggy/tests/unit_generallogger.cpp
Normal file
31
libdaggy/tests/unit_generallogger.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <daggy/GeneralLogger.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace daggy;
|
||||
|
||||
TEST_CASE("General Logger", "[general_logger]")
|
||||
{
|
||||
std::stringstream ss;
|
||||
GeneralLogger logger(ss);
|
||||
|
||||
SECTION("Logger logs a message")
|
||||
{
|
||||
std::string testMessage = "Test Message";
|
||||
logger.setLevel(LogLevel::INFO);
|
||||
logger.warn(testMessage);
|
||||
logger.shutdown();
|
||||
|
||||
auto captured = ss.str();
|
||||
REQUIRE(!captured.empty());
|
||||
REQUIRE(captured.find(testMessage) != std::string::npos);
|
||||
}
|
||||
|
||||
SECTION("Logger does not emit messages of higher levels")
|
||||
{
|
||||
logger.setLevel(LogLevel::INFO);
|
||||
logger.debug("Test Message");
|
||||
REQUIRE(ss.str().empty());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user