NDS3
1.0.0
API reference manual
|
Macros | |
#define | ndsLogStream(node, logLevel) if(!(node).isLogLevelEnabled(logLevel)) {} else (node).getLogger(logLevel) |
If the logging is enabled for the specified severity level then the macro returns the proper logging stream, otherwise it skips the logging operation. | |
#define | ndsDebugStream(node) ndsLogStream(node, nds::logLevel_t::debug) |
Log to the debug stream if the debug log level is enabled on the selected node. More... | |
#define | ndsInfoStream(node) ndsLogStream(node, nds::logLevel_t::info) |
Log to the info stream if the info log level is enabled on the selected node. More... | |
#define | ndsWarningStream(node) ndsLogStream(node, nds::logLevel_t::warning) |
Log to the warning stream if the warning log level is enabled on the selected node. More... | |
#define | ndsErrorStream(node) ndsLogStream(node, nds::logLevel_t::error) |
Log to the error stream if the error log level is enabled on the selected node. More... | |
Enumerations | |
enum | nds::logLevel_t : std::uint8_t { nds::logLevel_t::debug, nds::logLevel_t::info, nds::logLevel_t::warning, nds::logLevel_t::error, nds::logLevel_t::none } |
Defines the severities of the log information. More... | |
Functions | |
std::ostream & | nds::Base::getLogger (const logLevel_t logLevel) |
Retrieve a logging stream for the specified log level. More... | |
bool | nds::Base::isLogLevelEnabled (const logLevel_t logLevel) const |
Returns true if the logging for a particular severity level has been enabled. More... | |
void | nds::Base::setLogLevel (const logLevel_t logLevel) |
Enable the logging for a particular severity level. More... | |
std::ostream & | nds::BaseImpl::getLogger (const logLevel_t logLevel) |
Retrieve a stream that can be used for logging. More... | |
bool | nds::BaseImpl::isLogLevelEnabled (const logLevel_t logLevel) const |
Returns true if the logging for a particular severity level has been enabled. More... | |
virtual void | nds::BaseImpl::setLogLevel (const logLevel_t logLevel) |
Enable the logging for a particular severity level. More... | |
The Logging methods can be used to send debug, information, warning or errors to the control system.
The logging interface is control-system agnostic.
Each logged information is tied to a node, and the log level of each node can be set separately. For instance, it is possible to have the whole device (root node) with a log level set to "warning" and only a specific state machine set to "debug".
The logging level of each node can be set with Base::setLogLevel().
Each node provides a different std::ostream object for each severity level and for each thread. Your application can retrieve the std::ostream object by using Base::getLogger().
#define ndsDebugStream | ( | node | ) | ndsLogStream(node, nds::logLevel_t::debug) |
Log to the debug stream if the debug log level is enabled on the selected node.
The last logged element must be std::endl.
Example:
#define ndsErrorStream | ( | node | ) | ndsLogStream(node, nds::logLevel_t::error) |
Log to the error stream if the error log level is enabled on the selected node.
The last logged element must be std::endl.
Example:
#define ndsInfoStream | ( | node | ) | ndsLogStream(node, nds::logLevel_t::info) |
Log to the info stream if the info log level is enabled on the selected node.
The last logged element must be std::endl.
Example:
#define ndsWarningStream | ( | node | ) | ndsLogStream(node, nds::logLevel_t::warning) |
Log to the warning stream if the warning log level is enabled on the selected node.
The last logged element must be std::endl.
Example:
|
strong |
std::ostream& nds::BaseImpl::getLogger | ( | const logLevel_t | logLevel | ) |
Retrieve a stream that can be used for logging.
Logging streams are specific for the requested log level and the current thread.
logLevel | the severity level of the messages that will be logged througn the stream |
std::ostream& nds::Base::getLogger | ( | const logLevel_t | logLevel | ) |
Retrieve a logging stream for the specified log level.
You should use the NDS macros ndsDebugStream, ndsInfoStream, ndsWarningStream and ndsErrorStream in order to perform log operations: this increases the performances by avoiding non-necessary operations if the log has been disabled.
The log information must be terminated by std::endl.
Log streams are specific for each running thread in order to avoid multithreading related issues.
Example of usage:
or the preferred way:
logLevel | the level of the messages that will be logged to the stream |
bool nds::BaseImpl::isLogLevelEnabled | ( | const logLevel_t | logLevel | ) | const |
Returns true if the logging for a particular severity level has been enabled.
logLevel | the severity level for which the status is required |
bool nds::Base::isLogLevelEnabled | ( | const logLevel_t | logLevel | ) | const |
Returns true if the logging for a particular severity level has been enabled.
logLevel | the severity level for which the status is required |
|
virtual |
Enable the logging for a particular severity level.
logLevel | the severity level for which the logging is enabled. |
void nds::Base::setLogLevel | ( | const logLevel_t | logLevel | ) |
Enable the logging for a particular severity level.
The logging severity level will be set also on the node's children.
logLevel | the severity level for which the logging is enabled. |