fcf::NTest::Logger class
Package: fcfTest
File: test.hpp
Available from version: 1.0.1
A configurable logging utility providing multiple severity levels and customizable output formatting via static prefixes or functional callbacks
Detailed description
The
The logger filters messages based on the current
fcf::NTest::LL_FTL (Fatal),fcf::NTest::LL_ERR (Error),fcf::NTest::LL_WRN (Warning),fcf::NTest::LL_ATT (Attention),fcf::NTest::LL_LOG (Log),fcf::NTest::LL_INF (Info),fcf::NTest::LL_DBG (Debug),fcf::NTest::LL_TRC (Trace).
Usage Examples
1. Basic Logging
Using global shortcut functions for immediate output.
// Default level is LL_LOG
fcf::NTest::inf() << "System initialized." << std::endl;
fcf::NTest::err () << "Critical error detected!" << std::endl;
// Debug messages won't appear unless level is changed
fcf::NTest::dbg () << "This is hidden by default." << std::endl;
2. Customizing Prefixes
Adding static strings or dynamic functions (e.g., timestamps) to every log entry.
3. Changing Log Level
Adjusting verbosity at runtime.
Static methods
- Converts a string representation of a log level to its enum value.
- Converts an fcf::NTest::ELogLevel enumeration value into its corresponding human-readable string representation.
Methods
[CONSTRUCTOR]
Logger ()
- Default constructor that initializes a new logger instance with the default log level set to LL_LOG .
- Returns the current logging threshold level as an fcf::NTest::ELogLevel enumeration value.
- Sets the current logging threshold level, determining the minimum severity required for a message to be processed
- Returns a pointer to a static string representing the current log level name
- Sets the logger's verbosity threshold using a string identifier (e.g., "dbg" , "err" )
- Appends a static string as a prefix to all subsequent log messages produced by the logger.
- Adds a dynamic functional prefix to all subsequent log messages, allowing for real-time data injection such as timestamps or thread IDs
- Returns a reference to the output stream for fatal-level log messages. This level is used for critical failures that require immediate attention.
- Returns a reference to the output stream for error-level log messages. This level is used to report significant issues that do not necessarily terminate the application
- Returns a reference to the output stream for warning-level log messages. This level is used for warnings that require immediate attention.
- Returns a reference to the output stream for attention-level log messages. This level is used for important message that require attention.
- Returns a reference to the output stream for default level log messages. This level is used for simple message that require attention.
- Returns a reference to the output stream for info level log messages. This level is used for message with a secondary importance
- Returns a reference to the output stream for debug log messages. This logging level is used to output the debugging mesasge.
- Returns a reference to the output stream for trace log messages. This logging level is used to extract tracing data.
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.