Class: fcf::NTest::Logger
Package: fcfTest
File: test.hpp
Available from version: 1.0.1
Appends a static string as a prefix to all subsequent log messages produced by the logger.
The addedPrefixStr method allows you to attach a constant string to every log entry. This is useful for adding identifiers, such as module names, process IDs, or indentation, to the beginning of all log outputs.
Prefixes are stored in an internal list and are applied in the order they are added. If multiple prefixes are added, they will all appear before the actual log message.
Arguments
const std::string& a_prefix
- The string to be used as a prefix.
Example: Adding a simple module identifier
Useful for distinguishing logs from different components in a large system
fcf::NTest::logger().addedPrefixStr("[NETWORK] ");
fcf::NTest::inf() << "Connection established." << std::endl;
fcf::NTest::err() << "Timeout occurred." << std::endl;
Output:
[NETWORK] Connection established.
[NETWORK] Timeout occurred.
Example: Multiple prefixes
Prefixes are cumulative.
fcf::NTest::logger().addedPrefixStr("[CORE] ");
fcf::NTest::logger().addedPrefixStr(">> ");
fcf::NTest::log() << "System ready." << std::endl;
Output:
[CORE] >> System ready.