Some checks failed
Bigfoot / Build & Test Debug (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Debug (Unity Build: OFF) (push) Has been cancelled
Reviewed-on: #1 Co-authored-by: Romain BOULLARD <romain.boullard@protonmail.com> Co-committed-by: Romain BOULLARD <romain.boullard@protonmail.com>
139 lines
4.0 KiB
C++
139 lines
4.0 KiB
C++
/*********************************************************************
|
|
* \file Log.cpp
|
|
*
|
|
* \author Romain BOULLARD
|
|
* \date December 2022
|
|
*********************************************************************/
|
|
#include <System/Log/Log.hpp>
|
|
|
|
#include <Utils/Singleton.hpp>
|
|
|
|
#include <SystemTests/SystemTestsLogger_generated.hpp>
|
|
|
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace Bigfoot
|
|
{
|
|
class LogFixture: public ::testing::Test
|
|
{
|
|
protected:
|
|
void SetUp() override
|
|
{
|
|
SYSTEMTESTS_LOGGER = {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
|
|
}
|
|
|
|
static constexpr Flat::LogLevel QuillLogLevelToLogLevel(const quill::LogLevel p_level)
|
|
{
|
|
switch (p_level)
|
|
{
|
|
case quill::LogLevel::Debug:
|
|
return Flat::LogLevel::Debug;
|
|
case quill::LogLevel::TraceL3:
|
|
return Flat::LogLevel::Trace;
|
|
case quill::LogLevel::Info:
|
|
return Flat::LogLevel::Info;
|
|
case quill::LogLevel::Warning:
|
|
return Flat::LogLevel::Warn;
|
|
case quill::LogLevel::Error:
|
|
return Flat::LogLevel::Error;
|
|
case quill::LogLevel::Critical:
|
|
return Flat::LogLevel::Critical;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return Flat::LogLevel::Trace;
|
|
}
|
|
|
|
Log m_log;
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, RegisterLogger_ShouldRegisterTheLogger)
|
|
{
|
|
const quill::Logger* logger = m_log.RegisterLogger(SYSTEMTESTS_LOGGER);
|
|
EXPECT_TRUE(logger);
|
|
EXPECT_EQ(logger, m_log.GetLogger(SYSTEMTESTS_LOGGER));
|
|
EXPECT_EQ(logger->get_logger_name(), SYSTEMTESTS_LOGGER.m_name);
|
|
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), SYSTEMTESTS_LOGGER.m_level);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
|
|
{
|
|
EXPECT_FALSE(m_log.GetLogger(SYSTEMTESTS_LOGGER));
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, GetLogger_ShouldReturnTheLoggerIfItExists)
|
|
{
|
|
[[maybe_unused]]
|
|
const quill::Logger* logger = m_log.RegisterLogger(SYSTEMTESTS_LOGGER);
|
|
EXPECT_TRUE(m_log.GetLogger(SYSTEMTESTS_LOGGER));
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
|
|
{
|
|
const quill::Logger* logger = m_log.RegisterLogger(SYSTEMTESTS_LOGGER);
|
|
|
|
m_log.ChangeLoggerLogLevel(SYSTEMTESTS_LOGGER, Flat::LogLevel::Critical);
|
|
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), Flat::LogLevel::Critical);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, LogDebug)
|
|
{
|
|
Singleton<Log>::Lifetime singletonLifetime;
|
|
BIGFOOT_LOG_DEBUG(SYSTEMTESTS_LOGGER, "Hello");
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, LogTrace)
|
|
{
|
|
Singleton<Log>::Lifetime singletonLifetime;
|
|
BIGFOOT_LOG_TRACE(SYSTEMTESTS_LOGGER, "Hello");
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, LogInfo)
|
|
{
|
|
Singleton<Log>::Lifetime singletonLifetime;
|
|
BIGFOOT_LOG_INFO(SYSTEMTESTS_LOGGER, "Hello");
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, LogWarn)
|
|
{
|
|
Singleton<Log>::Lifetime singletonLifetime;
|
|
BIGFOOT_LOG_WARN(SYSTEMTESTS_LOGGER, "Hello");
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, LogError)
|
|
{
|
|
Singleton<Log>::Lifetime singletonLifetime;
|
|
BIGFOOT_LOG_ERROR(SYSTEMTESTS_LOGGER, "Hello");
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(LogFixture, LogFatal)
|
|
{
|
|
Singleton<Log>::Lifetime singletonLifetime;
|
|
BIGFOOT_LOG_FATAL(SYSTEMTESTS_LOGGER, "Hello");
|
|
}
|
|
} // namespace Bigfoot
|
|
#endif
|