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

multiLine from class fcf::NTest::Logger::Prefix

Property: multiLine = false

Type: bool

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

Package: fcfTest

File: test.hpp

Available from version: 1.1.13

Determines if the prefix should be applied to every line of a multi-line message.

The multiLine property controls how prefixes are handled when a single log message contains multiple lines (separated by \n).

    If false (default): The prefix is only applied to the very first line of the message. Subsequent lines will not have the prefix.
  • If true: The prefix is prepended to every single line within the message, ensuring consistent indentation or labeling for block logs.

Example: Handling multi-line log messages

Demonstrating the difference between single-line and multi-line prefix application.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> #include <iostream> int main(int a_argc, char* a_argv[]) { fcf::NTest::Logger& logger = fcf::NTest::logger(); logger.clearPrefixes(false); // 1. Setup a multi-line prefix fcf::NTest::Logger::Prefix multiLinePrefix; multiLinePrefix.name = "multi_line_test"; multiLinePrefix.multiLine = true; multiLinePrefix.category = fcf::NTest::LMC_ALL; multiLinePrefix.prefix = " > "; logger.appendPrefix(multiLinePrefix); // 2. Log a message with multiple lines logger.log() << "Line One\nLine Two\nLine Three" << std::endl; // 3. Setup a single-line prefix logger.clearPrefixes(false); fcf::NTest::Logger::Prefix singleLinePrefix; singleLinePrefix.name = "single_line_test"; singleLinePrefix.multiLine = false; singleLinePrefix.category = fcf::NTest::LMC_ALL; singleLinePrefix.prefix = " > "; logger.appendPrefix(singleLinePrefix); // 4. Log the same multi-line message logger.log() << "Line One\nLine Two\nLine Three" << std::endl; return 0; }

Output:

> Line One > Line Two > Line Three > Line One Line Two Line Three

When multiLine is true, every line receives the prefix. When false, only the first line is affected.