LMC_SYSTEM_GROUP from enum fcf::NTest::ELogMessageCategory
Value: fcf::NTest::LMC_SYSTEM_GROUP
= 2147483648
Enum: fcf::NTest::ELogMessageCategory
Package: fcfTest
File:
test.hpp
Available from version: 1.1.14
A category bit mask representing internal system messages. Messages in this group are typically treated as internal software events and are not output to the logging output stream.
The fcf::NTest::LMC_SYSTEM_GROUP category is a special bitmask used to identify messages that are part of the framework's internal system operations. When a log message is assigned this category, the fcf::NTest::Logger automatically sets the system flag to true.
This mechanism allows developers to create custom fcf::NTest::Logger::Format or fcf::NTest::Logger::Prefix handlers that can distinguish between standard user-generated logs and internal messages containing test progress information.
Example: Handling System Messages with a Custom Formatter
Demonstrating how to use the fcf::NTest::LMC_SYSTEM_GROUP category to trigger special formatting for system-level events within a custom formatter.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
// Define a custom formatter that detects system messages
fcf::NTest::Logger::FormatFunction systemEventFormatter = []( fcf::NTest::Logger&, fcf::NTest::Logger::MessageContext& a_context) {
if (a_context.system) {
// If it's a system message, wrap it in a decorative box
std::stringstream info;
info << "\n========================================\n"
<< "[SYSTEM EVENT " << std::hex << a_context.category << "] " << a_context.message << "\n"
<< "========================================\n";
a_context.message = info.str();
// Reset the system message flag so that the data is output to the stream
a_context.system = false;
}
};
FCF_TEST_DECLARE("SystemDemo", "Formatter", "SystemGroupTest") {
// Log a standard user message (system will be false)
fcf::NTest::log() << "This is a normal user log." << std::endl;
// Log a message using the LMC_SYSTEM_GROUP category
// This will trigger the special formatting because system becomes true
fcf::NTest::log(fcf::NTest::LMC_SYSTEM_GROUP) << "Internal framework heartbeat." << std::endl;
}
int main(int a_argc, char* a_argv[]) {
fcf::NTest::Logger& logger = fcf::NTest::logger();
// Setup the logger with our custom formatter
fcf::NTest::Logger::Format format;
format.name = "sys-event-format";
format.handler = systemEventFormatter;
logger.appendFormat(format);
bool error = false;
// Run the test suite
fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error);
return error ? 1 : 0;
}
Output:
========================================
[SYSTEM EVENT 80010001]
========================================
========================================
[SYSTEM EVENT 80020001]
========================================
Performing the test: "SystemDemo" -> "Formatter" -> "SystemGroupTest" ...
> This is a normal user log.
========================================
[SYSTEM EVENT 80000000] Internal framework heartbeat.
========================================
[SUCCESS] Test completed successfully (0.000`008`510 sec)
========================================
[SYSTEM EVENT 80020003]
========================================
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`008`510 sec
========================================
[SYSTEM EVENT 80010002]
========================================
The application must be run by specifying the format via a command-line parameter:
app --test-format "sys-event-format"