6 #ifndef HPP_CENTROIDAL_DYNAMICS_LOGGER_HH
7 #define HPP_CENTROIDAL_DYNAMICS_LOGGER_HH
15 #include <Eigen/Dense>
17 #include "boost/assign.hpp"
25 #define LOGGER_VERBOSITY_ALL
27 #define SEND_MSG(msg, type) getLogger().sendMsg(msg, type, __FILE__, __LINE__)
29 #ifdef LOGGER_VERBOSITY_ERROR
30 #define SEND_DEBUG_MSG(msg)
31 #define SEND_INFO_MSG(msg)
32 #define SEND_WARNING_MSG(msg)
33 #define SEND_ERROR_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR)
34 #define SEND_DEBUG_STREAM_MSG(msg)
35 #define SEND_INFO_STREAM_MSG(msg)
36 #define SEND_WARNING_STREAM_MSG(msg)
37 #define SEND_ERROR_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR_STREAM)
40 #ifdef LOGGER_VERBOSITY_WARNING_ERROR
41 #define SEND_DEBUG_MSG(msg)
42 #define SEND_INFO_MSG(msg)
43 #define SEND_WARNING_MSG(msg) SEND_MSG(msg, MSG_TYPE_WARNING)
44 #define SEND_ERROR_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR)
45 #define SEND_DEBUG_STREAM_MSG(msg)
46 #define SEND_INFO_STREAM_MSG(msg) #define SEND_WARNING_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_WARNING_STREAM)
47 #define SEND_ERROR_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR_STREAM)
50 #ifdef LOGGER_VERBOSITY_INFO_WARNING_ERROR
51 #define SEND_DEBUG_MSG(msg)
52 #define SEND_INFO_MSG(msg) SEND_MSG(msg, MSG_TYPE_INFO)
53 #define SEND_WARNING_MSG(msg) SEND_MSG(msg, MSG_TYPE_WARNING)
54 #define SEND_ERROR_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR)
55 #define SEND_DEBUG_STREAM_MSG(msg)
56 #define SEND_INFO_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_INFO_STREAM)
57 #define SEND_WARNING_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_WARNING_STREAM)
58 #define SEND_ERROR_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR_STREAM)
61 #ifdef LOGGER_VERBOSITY_ALL
62 #define SEND_DEBUG_MSG(msg) SEND_MSG(msg, MSG_TYPE_DEBUG)
63 #define SEND_INFO_MSG(msg) SEND_MSG(msg, MSG_TYPE_INFO)
64 #define SEND_WARNING_MSG(msg) SEND_MSG(msg, MSG_TYPE_WARNING)
65 #define SEND_ERROR_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR)
66 #define SEND_DEBUG_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_DEBUG_STREAM)
67 #define SEND_INFO_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_INFO_STREAM)
68 #define SEND_WARNING_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_WARNING_STREAM)
69 #define SEND_ERROR_STREAM_MSG(msg) SEND_MSG(msg, MSG_TYPE_ERROR_STREAM)
82 MSG_TYPE_ERROR_STREAM = 7
93 std::string
toString(
const std::vector<T>& v,
const std::string separator =
", ") {
95 for (
int i = 0; i < v.size() - 1; i++) ss << v[i] << separator;
96 ss << v[v.size() - 1];
100 template <
typename T,
int n>
101 std::string
toString(
const Eigen::MatrixBase<T>& v,
const std::string separator =
", ") {
102 if (v.rows() > v.cols())
return toString(v.transpose(), separator);
103 std::stringstream ss;
121 Logger(
double timeSample = 0.001,
double streamPrintPeriod = 1.0);
135 void sendMsg(std::string msg, MsgType type,
const char* file =
"",
int line = 0);
139 bool setTimeSample(
double t);
142 bool setStreamPrintPeriod(
double s);
Definition: logger.hh:118
double m_streamPrintPeriod
specify the period of call of the countdown method
Definition: logger.hh:150
bool isInfoMsg(MsgType m)
Definition: logger.hh:163
bool isStreamMsg(MsgType m)
Definition: logger.hh:156
double m_printCountdown
specify the time period of the stream prints
Definition: logger.hh:151
std::map< std::string, double > m_stream_msg_counters
every time this is < 0 (i.e. every _streamPrintPeriod sec) print stuff
Definition: logger.hh:154
bool isWarningMsg(MsgType m)
Definition: logger.hh:165
bool isErrorMsg(MsgType m)
Definition: logger.hh:167
double m_timeSample
verbosity of the logger
Definition: logger.hh:149
LoggerVerbosity m_lv
Definition: logger.hh:148
bool isDebugMsg(MsgType m)
Definition: logger.hh:161
void setVerbosity(LoggerVerbosity lv)
~Logger()
Definition: logger.hh:124
#define CENTROIDAL_DYNAMICS_DLLAPI
Definition: local_config.hh:52
MSG_TYPE_ERROR
Definition: logger.hh:78
MSG_TYPE_INFO_STREAM
Definition: logger.hh:80
MSG_TYPE_INFO
Definition: logger.hh:76
MSG_TYPE_DEBUG_STREAM
Definition: logger.hh:79
VERBOSITY_INFO_WARNING_ERROR
Definition: logger.hh:110
MSG_TYPE_WARNING_STREAM
Definition: logger.hh:81
VERBOSITY_WARNING_ERROR
Definition: logger.hh:111
VERBOSITY_ERROR
Definition: logger.hh:112
MSG_TYPE_DEBUG
Definition: logger.hh:75
MSG_TYPE_WARNING
Definition: logger.hh:77
VERBOSITY_ALL
Definition: logger.hh:109
Definition: centroidal_dynamics.hh:14
std::string toString(const T &v)
Definition: logger.hh:86
Logger & getLogger()
Definition: logger.cpp:21