multiLine from class fcf::NTest::Logger::Prefix
Type:
Class:
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
- If
- 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
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.