Type: std::string
Class: fcf::NTest::Logger::Format
Package: fcfTest
File: test.hpp
Available from version: 1.1.13
The unique identifier for the output format.
The name property is a string identifier used to distinguish between different output formats within the fcf::NTest::Logger.
When a logger target is configured with a specific format, the logger uses this name to look up the corresponding formatting function. For example, if a target is set to use the "junit" format, the logger will search for a registered format whose name matches this string.
Example: Defining a custom format name
Demonstrating how to assign a custom name to fcf::NTest::Logger::FormatSettings::name to create a unique format identifier.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <iostream>
FCF_TEST_DECLARE("FormatDemo", "Settings", "CustomNameTest") {
// 1. Create a logger instance
fcf::NTest::Logger myLogger;
// 2. Create Format object
fcf::NTest::Logger::Format format;
// 3. Set the name property to a custom identifier
format.name = "my_custom_format";
// In a real application, you would also assign a formatting function here:
// format.handler = [](fcf::NTest::Logger& a_logger, fcf::NTest::Logger::MessageContext& a_context) { ... };
// 5. Register the format with the logger
myLogger.appendFormat(format);
// 6. Verify that the format was added correctly
fcf::NTest::Logger::Logger::Formats currentFormats = myLogger.formats();
FCF_TEST(!currentFormats.empty(), "Logger should contain the new format");
FCF_TEST(currentFormats.back().name == "my_custom_format", "The format name should match the assigned value");
}
int main(int a_argc, char* a_argv[]) {
bool error = false;
fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error);
return error ? 1 : 0;
}
Output:
Performing the test: "LoggerDemo" -> "Format" -> "CustomFormatTest" ...
[SUCCESS] Test completed successfully (0.000`002`675 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`002`675 sec