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

setLevelStr() method from fcf::NTest::Logger class

void setLevelStr(const char* a_level)

Class: fcf::NTest::Logger

Package: fcfTest

File: test.hpp

Available from version: 1.0.1

Sets the logger's verbosity threshold using a string identifier (e.g., "dbg", "err")

The setLevelStr method provides a convenient way to adjust the logging threshold at runtime using human-readable string identifiers. It internally maps the provided string to the corresponding fcf::NTest::ELogLevel enumeration

Arguments

cons char* a_level
- A pointer to a null-terminated string representing the desired log level. Valid identifiers include: "off", "ftl", "err", "wrn", "att", "log", "inf", "dbg", "trc", "all".

Example: Basic usage

Switching the logger to debug mode using a string.

// Set level to Debug fcf::NTest::logger().setLevelStr("dbg"); fcf::NTest::dbg() << "Debug information is now visible." << std::endl;

Example: Integration with command-line logic

Commonly used when parsing configuration or command-line arguments to set verbosity

std::string userConfiguredLevel = "err"; fcf::NTest::logger().setLevelStr(userConfiguredLevel.c_str()); fcf::NTest::inf() << "This message will not be displayed."; fcf::NTest::err() << "This message will be displayed.";