Skip to content

Commit f17106c

Browse files
jmirabelOlivier Stasse
authored andcommitted
Clean code.
1 parent 385429e commit f17106c

File tree

1 file changed

+14
-32
lines changed

1 file changed

+14
-32
lines changed

include/dynamic-graph/logger.h

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,7 @@ class Logger {
191191
* to decrement the internal Logger's counter. */
192192
void countdown();
193193

194-
/** Check whether next message should be accepted.
195-
* \note See Logger::stream to see how to use it.
196-
* This will modify the counter associated to lineId as if it was
197-
* published. It should thus be used in conjunction with Logger::stream.
198-
*/
199-
bool acceptMsg (MsgType m, const std::string& lineId) {
200-
if ((m & MSG_TYPE_TYPE_BITS) < m_lv)
201-
return false;
202-
203-
// if print is allowed by current verbosity level
204-
if (isStreamMsg(m)) return checkStreamPeriod(lineId);
205-
return true;
206-
}
207-
208-
/** The most efficient logging method is
209-
* \code
210-
* if (logger.acceptMsg(type, lineId))
211-
* logger.stream() << "my message\n";
212-
* \endcode
194+
/** Get an output stream independently of the debug level.
213195
*/
214196
RTLoggerStream stream() {
215197
return ::dynamicgraph::RealTimeLogger::instance().emptyStream();
@@ -272,22 +254,22 @@ class Logger {
272254
return (m & MSG_TYPE_STREAM_BIT);
273255
}
274256

275-
bool isDebugMsg(MsgType m) {
276-
return m == MSG_TYPE_DEBUG_STREAM || m == MSG_TYPE_DEBUG;
277-
}
278-
279-
bool isInfoMsg(MsgType m) {
280-
return m == MSG_TYPE_INFO_STREAM || m == MSG_TYPE_INFO;
281-
}
282-
283-
bool isWarningMsg(MsgType m) {
284-
return m == MSG_TYPE_WARNING_STREAM || m == MSG_TYPE_WARNING;
285-
}
257+
/** Check whether a message of type \m and from \c lineId should be accepted.
258+
* \note If \c is a stream type, the internal counter associated to \c lineId
259+
* is updated.
260+
*/
261+
bool acceptMsg (MsgType m, const std::string& lineId) {
262+
if ((m & MSG_TYPE_TYPE_BITS) < m_lv)
263+
return false;
286264

287-
bool isErrorMsg(MsgType m) {
288-
return m == MSG_TYPE_ERROR_STREAM || m == MSG_TYPE_ERROR;
265+
// if print is allowed by current verbosity level
266+
if (isStreamMsg(m)) return checkStreamPeriod(lineId);
267+
return true;
289268
}
290269

270+
/** Check whether a message from \c lineId should be accepted.
271+
* \note The internal counter associated to \c lineId is updated.
272+
*/
291273
bool checkStreamPeriod (const std::string& lineId);
292274
};
293275

0 commit comments

Comments
 (0)