Commit f17106c5 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by olivier stasse
Browse files

Clean code.

parent 385429eb
...@@ -191,25 +191,7 @@ public: ...@@ -191,25 +191,7 @@ public:
* to decrement the internal Logger's counter. */ * to decrement the internal Logger's counter. */
void countdown(); void countdown();
/** Check whether next message should be accepted. /** Get an output stream independently of the debug level.
* \note See Logger::stream to see how to use it.
* This will modify the counter associated to lineId as if it was
* published. It should thus be used in conjunction with Logger::stream.
*/
bool acceptMsg (MsgType m, const std::string& lineId) {
if ((m & MSG_TYPE_TYPE_BITS) < m_lv)
return false;
// if print is allowed by current verbosity level
if (isStreamMsg(m)) return checkStreamPeriod(lineId);
return true;
}
/** The most efficient logging method is
* \code
* if (logger.acceptMsg(type, lineId))
* logger.stream() << "my message\n";
* \endcode
*/ */
RTLoggerStream stream() { RTLoggerStream stream() {
return ::dynamicgraph::RealTimeLogger::instance().emptyStream(); return ::dynamicgraph::RealTimeLogger::instance().emptyStream();
...@@ -272,22 +254,22 @@ protected: ...@@ -272,22 +254,22 @@ protected:
return (m & MSG_TYPE_STREAM_BIT); return (m & MSG_TYPE_STREAM_BIT);
} }
bool isDebugMsg(MsgType m) { /** Check whether a message of type \m and from \c lineId should be accepted.
return m == MSG_TYPE_DEBUG_STREAM || m == MSG_TYPE_DEBUG; * \note If \c is a stream type, the internal counter associated to \c lineId
} * is updated.
*/
bool isInfoMsg(MsgType m) { bool acceptMsg (MsgType m, const std::string& lineId) {
return m == MSG_TYPE_INFO_STREAM || m == MSG_TYPE_INFO; if ((m & MSG_TYPE_TYPE_BITS) < m_lv)
} return false;
bool isWarningMsg(MsgType m) {
return m == MSG_TYPE_WARNING_STREAM || m == MSG_TYPE_WARNING;
}
bool isErrorMsg(MsgType m) { // if print is allowed by current verbosity level
return m == MSG_TYPE_ERROR_STREAM || m == MSG_TYPE_ERROR; if (isStreamMsg(m)) return checkStreamPeriod(lineId);
return true;
} }
/** Check whether a message from \c lineId should be accepted.
* \note The internal counter associated to \c lineId is updated.
*/
bool checkStreamPeriod (const std::string& lineId); bool checkStreamPeriod (const std::string& lineId);
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment