@@ -31,38 +31,86 @@ class CustomEntity : public Entity {
31
31
explicit CustomEntity (const std::string &n) : Entity(n) {
32
32
logger_.setTimeSample (0.001 );
33
33
logger_.setStreamPrintPeriod (0.005 );
34
+
35
+ logger_.setVerbosity (VERBOSITY_NONE);
36
+ BOOST_CHECK_EQUAL (logger_.getVerbosity (), VERBOSITY_NONE);
37
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_DEBUG ).isNull ());
38
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_INFO ).isNull ());
39
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_WARNING).isNull ());
40
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_ERROR ).isNull ());
41
+
42
+ logger_.setVerbosity (VERBOSITY_ERROR);
43
+ BOOST_CHECK_EQUAL (logger_.getVerbosity (), VERBOSITY_ERROR);
44
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_DEBUG ).isNull ());
45
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_INFO ).isNull ());
46
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_WARNING).isNull ());
47
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_ERROR ).isNull ());
48
+
49
+ logger_.setVerbosity (VERBOSITY_WARNING_ERROR);
50
+ BOOST_CHECK_EQUAL (logger_.getVerbosity (), VERBOSITY_WARNING_ERROR);
51
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_DEBUG ).isNull ());
52
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_INFO ).isNull ());
53
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_WARNING).isNull ());
54
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_ERROR ).isNull ());
55
+
56
+ logger_.setVerbosity (VERBOSITY_INFO_WARNING_ERROR);
57
+ BOOST_CHECK_EQUAL (logger_.getVerbosity (), VERBOSITY_INFO_WARNING_ERROR);
58
+ BOOST_CHECK ( logger_.stream (MSG_TYPE_DEBUG ).isNull ());
59
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_INFO ).isNull ());
60
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_WARNING).isNull ());
61
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_ERROR ).isNull ());
62
+
34
63
logger_.setVerbosity (VERBOSITY_ALL);
35
- LoggerVerbosity alv = logger_.getVerbosity ();
36
- BOOST_CHECK (alv == VERBOSITY_ALL);
64
+ BOOST_CHECK_EQUAL (logger_.getVerbosity (), VERBOSITY_ALL);
65
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_DEBUG ).isNull ());
66
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_INFO ).isNull ());
67
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_WARNING).isNull ());
68
+ BOOST_CHECK (!logger_.stream (MSG_TYPE_ERROR ).isNull ());
37
69
}
38
70
39
71
~CustomEntity () {}
40
72
void testDebugTrace () {
41
- sendMsg (" This is a message of level MSG_TYPE_DEBUG" , MSG_TYPE_DEBUG);
42
- sendMsg (" This is a message of level MSG_TYPE_INFO" , MSG_TYPE_INFO);
43
- sendMsg (" This is a message of level MSG_TYPE_WARNING" , MSG_TYPE_WARNING);
44
- sendMsg (" This is a message of level MSG_TYPE_ERROR" , MSG_TYPE_ERROR);
45
- sendMsg (" This is a message of level MSG_TYPE_DEBUG_STREAM" ,
46
- MSG_TYPE_DEBUG_STREAM);
47
- sendMsg (" This is a message of level MSG_TYPE_INFO_STREAM" ,
48
- MSG_TYPE_INFO_STREAM);
49
- sendMsg (" This is a message of level MSG_TYPE_WARNING_STREAM" ,
50
- MSG_TYPE_WARNING_STREAM);
51
- sendMsg (" This is a message of level MSG_TYPE_ERROR_STREAM" ,
52
- MSG_TYPE_ERROR_STREAM);
73
+ logger_.stream (MSG_TYPE_DEBUG)
74
+ << " This is a message of level MSG_TYPE_DEBUG\n " ;
75
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
76
+ logger_.stream (MSG_TYPE_INFO)
77
+ << " This is a message of level MSG_TYPE_INFO\n " ;
78
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
79
+ logger_.stream (MSG_TYPE_WARNING)
80
+ << " This is a message of level MSG_TYPE_WARNING\n " ;
81
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
82
+ logger_.stream (MSG_TYPE_ERROR)
83
+ << " This is a message of level MSG_TYPE_ERROR\n " ;
84
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
85
+ logger_.stream (MSG_TYPE_DEBUG_STREAM)
86
+ << " This is a message of level MSG_TYPE_DEBUG_STREAM\n " ;
87
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
88
+ logger_.stream (MSG_TYPE_INFO_STREAM)
89
+ << " This is a message of level MSG_TYPE_INFO_STREAM\n " ;
90
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
91
+ logger_.stream (MSG_TYPE_WARNING_STREAM)
92
+ << " This is a message of level MSG_TYPE_WARNING_STREAM\n " ;
93
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
94
+ logger_.stream (MSG_TYPE_ERROR_STREAM)
95
+ << " This is a message of level MSG_TYPE_ERROR_STREAM\n " ;
53
96
/* Add test toString */
97
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
54
98
double q = 1.0 ;
55
- sendMsg (" Value to display: " + toString (q));
99
+ logger_.stream () << " Value to display: " + toString (q) << ' \n ' ;
100
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
56
101
std::vector<double > vq;
57
102
vq.resize (3 );
58
103
vq[0 ] = 1.0 ;
59
104
vq[1 ] = 2.0 ;
60
105
vq[2 ] = 3.0 ;
61
- sendMsg (" Value to display: " + toString (vq));
62
- sendMsg (" Value to display: " + toString (vq, 3 , 10 ));
106
+ logger_.stream (MSG_TYPE_INFO) << " Value to display: " << toString (vq) << ' \n ' ;
107
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
108
+ logger_.stream (MSG_TYPE_INFO) << " Value to display: " << toString (vq, 3 , 10 ) << ' \n ' ;
109
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
63
110
Eigen::Matrix<double , 3 , 3 > an_eig_m;
64
- an_eig_m.Ones ();
65
- sendMsg (" Value to display: " + toString (an_eig_m));
111
+ an_eig_m.setOnes ();
112
+ logger_.stream (MSG_TYPE_INFO) << " Value to display: " << toString (an_eig_m) << ' \n ' ;
113
+ dynamicgraph::RealTimeLogger::instance ().spinOnce ();
66
114
logger_.countdown ();
67
115
}
68
116
};
@@ -84,8 +132,8 @@ BOOST_AUTO_TEST_CASE(debug_logger) {
84
132
85
133
entity.setTimeSample (0.002 );
86
134
BOOST_CHECK_EQUAL (entity.getTimeSample (), 0.002 );
87
- entity.setStreamPrintPeriod (0.004 );
88
- BOOST_CHECK_EQUAL (entity.getStreamPrintPeriod (), 0.004 );
135
+ entity.setStreamPrintPeriod (0.002 );
136
+ BOOST_CHECK_EQUAL (entity.getStreamPrintPeriod (), 0.002 );
89
137
90
138
for (unsigned int i = 0 ; i < 10000 ; i++) {
91
139
entity.testDebugTrace ();
0 commit comments