Adding a general logger and integrating it with daggyr

This commit is contained in:
Ian Roddis
2022-02-04 11:58:45 -04:00
parent 57e93b5045
commit ea3f67f226
8 changed files with 245 additions and 20 deletions

View File

@@ -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

View 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());
}
}