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

name from class fcf::NTest::Logger::Prefix

Property: name

Type: std::string

Class: fcf::NTest::Logger::Prefix

Package: fcfTest

File: test.hpp

Available from version: 1.1.13

The name of the prefix setting.

The name property specifies a unique identifier for a prefix configuration. This name is used by the logger to manage, update, or replace specific prefix settings within the logger's internal registry.

When adding a prefix with an existing name, the logger will overwrite the previous configuration associated with that name, allowing for dynamic updates of logging styles during runtime.

Example: Configuring a named prefix

Demonstrating how to use the 'name' property to define a unique prefix that can be updated later.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> int main(int a_argc, char* a_argv[]) { // 1. Access the global logger fcf::NTest::Logger& logger = fcf::NTest::logger(); // 2. Create a new Prefix object fcf::NTest::Logger::Prefix prefix; // 3. Set the unique name for this prefix prefix.name = "timestamp_prefix"; // 4. Set the string to be used as a prefix prefix.multiLine = false; prefix.category = fcf::NTest::LMC_ALL; prefix.prefix = "[TIME] "; // 5. Apply the prefix to the logger logger.appendPrefix(prefix); // 6. Log a message to see the result logger.log() << "Hello, world!" << std::endl; // 7. Update the existing prefix by using the same name fcf::NTest::Logger::Prefix updatedPrefix; updatedPrefix.name = "timestamp_prefix"; updatedPrefix.multiLine = false; updatedPrefix.category = fcf::NTest::LMC_ALL; updatedPrefix.prefix = "[NEW_TIME] "; logger.appendPrefix(updatedPrefix); // 8. Log again to see the updated prefix logger.log() << "Testing updates..." << std::endl; return 0; }

Output:

> [TIME] Hello, world! > [NEW_TIME] Testing updates...

The logger successfully applied the first prefix, and then replaced it when a new setting with the same name was provided.