FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

Format class
From fcf::NTest::Logger class

Type:
class fcf::NTest::Logger::Format

Owner class: fcf::NTest::Logger

Package: fcfTest

File: test.hpp

Available from version: 1.1.13

A configuration structure used to define the name of a specific output format for the logger.

The fcf::NTest::Logger::FormatSettings structure is a lightweight configuration object used by the fcf::NTest::Logger to identify and apply specific formatting rules. Each Format in the logger contains a FormatSettings object, which primarily holds the unique identifier (name) of the format. This allows the logger to match incoming messages with the appropriate formatting function based on the target's requirements.

Properties
std::string name
- The unique identifier for the output format.
fcf::NTest::Logger::DataFactory dataFactory
- A factory function used to initialize and provide a unique fcf::NTest::SharedPtrAny data object for a specific fcf::NTest::Logger::OutputTarget and fcf::NTest::Logger::Format combination.
fcf::NTest::Logger::FormatFunction handler
- A callback function responsible for formatting the log message content.

Example: Custom Format Configuration

Demonstrates how to manually create and use FormatSettings to define a custom format name within the logger's ecosystem.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> FCF_TEST_DEFINE("LoggerDemo", "Format", "CustomFormatTest") { // 1. Create a new Logger instance fcf::NTest::Logger myLogger; // 2. Create Format object fcf::NTest::Logger::Format format; format.name = "custom_xml"; // 3. Apply the format to the logger myLogger.appendFormat(format); // 4. Verify the configuration fcf::NTest::Logger::Formats currentFormats = myLogger.formats(); FCF_TEST(!currentFormats.empty(), "Logger should have at least one format"); FCF_TEST(currentFormats.back().name == "custom_xml", "Format name should match"); } 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`005`906 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`005`906 sec