This commit is contained in:
@ -24,14 +24,12 @@ IAT_BEGIN_BLOCK(Core, Logger)
|
||||
static constexpr const char *LOG_FILE = "iacore_test_log.txt";
|
||||
|
||||
auto test_file_logging() -> bool {
|
||||
// 1. Enable logging to disk
|
||||
|
||||
const auto res = Logger::enable_logging_to_disk(LOG_FILE);
|
||||
IAT_CHECK(res.has_value());
|
||||
|
||||
// 2. Set level to Trace to ensure we capture everything
|
||||
Logger::set_log_level(Logger::LogLevel::Trace);
|
||||
|
||||
// 3. Log unique messages
|
||||
const String msg_info = "Test_Info_Msg_123";
|
||||
const String msg_err = "Test_Error_Msg_456";
|
||||
const String msg_warn = "Test_Warn_Msg_789";
|
||||
@ -40,10 +38,8 @@ auto test_file_logging() -> bool {
|
||||
Logger::error("{}", msg_err);
|
||||
Logger::warn("{}", msg_warn);
|
||||
|
||||
// 4. Flush
|
||||
Logger::flush_logs();
|
||||
|
||||
// 5. Read back
|
||||
auto read_res = FileOps::read_text_file(LOG_FILE);
|
||||
if (!read_res) {
|
||||
std::cout << console::YELLOW << " Warning: Could not read log file ("
|
||||
@ -58,7 +54,6 @@ auto test_file_logging() -> bool {
|
||||
IAT_CHECK(content.find(msg_err) != String::npos);
|
||||
IAT_CHECK(content.find(msg_warn) != String::npos);
|
||||
|
||||
// Check for log tags
|
||||
IAT_CHECK(content.find("INFO") != String::npos);
|
||||
IAT_CHECK(content.find("ERROR") != String::npos);
|
||||
IAT_CHECK(content.find("WARN") != String::npos);
|
||||
@ -67,7 +62,7 @@ auto test_file_logging() -> bool {
|
||||
}
|
||||
|
||||
auto test_log_levels() -> bool {
|
||||
// 1. Set level to Warn (Trace < Debug < Info < Warn < Error)
|
||||
|
||||
Logger::set_log_level(Logger::LogLevel::Warn);
|
||||
|
||||
const String unique_info = "Hidden_Info_Msg";
|
||||
@ -85,9 +80,8 @@ auto test_log_levels() -> bool {
|
||||
|
||||
const String content = *read_res;
|
||||
|
||||
// Info should NOT be present
|
||||
IAT_CHECK(content.find(unique_info) == String::npos);
|
||||
// Warn SHOULD be present
|
||||
|
||||
IAT_CHECK(content.find(unique_warn) != String::npos);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user