utest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include "ros/console.h"
31 
32 #include "log4cxx/appenderskeleton.h"
33 #include "log4cxx/spi/loggingevent.h"
34 
35 #include <vector>
36 #include <stdexcept>
37 
38 #include <gtest/gtest.h>
39 
40 #include <boost/shared_array.hpp>
41 
42 class TestAppender : public log4cxx::AppenderSkeleton
43 {
44 public:
45  struct Info
46  {
47  log4cxx::LevelPtr level_;
48  std::string message_;
49  std::string logger_name_;
50  };
51 
52  typedef std::vector<Info> V_Info;
53 
54  V_Info info_;
55 
56 protected:
57  virtual void append(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool&)
58  {
59  Info info;
60  info.level_ = event->getLevel();
61  info.message_ = event->getMessage();
62  info.logger_name_ = event->getLoggerName();
63 
64  info_.push_back( info );
65  }
66 
67  virtual void close()
68  {
69  }
70  virtual bool requiresLayout() const
71  {
72  return false;
73  }
74 };
75 
76 class TestAppenderWithThrow : public log4cxx::AppenderSkeleton
77 {
78 protected:
79  virtual void append(const log4cxx::spi::LoggingEventPtr&, log4cxx::helpers::Pool&)
80  {
81  throw std::runtime_error("This should be caught");
82  }
83 
84  virtual void close()
85  {
86  }
87  virtual bool requiresLayout() const
88  {
89  return false;
90  }
91 };
92 
94 {
95  BasicFilter(bool enabled)
96  : enabled_(enabled)
97  {}
98 
99  inline virtual bool isEnabled() { return enabled_; };
100 
101  bool enabled_;
102 };
103 
104 BasicFilter g_filter(true);
105 
106 #define DEFINE_COND_TESTS(name, macro_base, level, log4cxx_level) \
107  TEST(RosConsole, name##Cond) \
108  { \
109  TestAppender* appender = new TestAppender; \
110  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
111  macro_base##_COND(true, "Testing %d %d %d", 1, 2, 3); \
112  macro_base##_COND(false, "Testing %d %d %d", 1, 2, 3); \
113  ASSERT_EQ((int)appender->info_.size(), 1); \
114  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
115  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
116  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
117  } \
118  TEST(RosConsole, name##NamedCond) \
119  { \
120  TestAppender* appender = new TestAppender; \
121  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
122  macro_base##_COND_NAMED(true, "test", "Testing %d %d %d", 1, 2, 3); \
123  macro_base##_COND_NAMED(false, "test", "Testing %d %d %d", 1, 2, 3); \
124  ASSERT_EQ((int)appender->info_.size(), 1); \
125  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
126  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
127  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
128  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
129  } \
130  TEST(RosConsole, name##StreamCond) \
131  { \
132  TestAppender* appender = new TestAppender; \
133  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
134  macro_base##_STREAM_COND(true, "Testing " << 1 << " " << 2 << " " << 3); \
135  macro_base##_STREAM_COND(false, "Testing " << 1 << " " << 2 << " " << 3); \
136  ASSERT_EQ((int)appender->info_.size(), 1); \
137  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
138  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
139  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
140  } \
141  TEST(RosConsole, name##StreamCondNamed) \
142  { \
143  TestAppender* appender = new TestAppender; \
144  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
145  macro_base##_STREAM_COND_NAMED(true, "test", "Testing " << 1 << " " << 2 << " " << 3); \
146  macro_base##_STREAM_COND_NAMED(false, "test", "Testing " << 1 << " " << 2 << " " << 3); \
147  ASSERT_EQ((int)appender->info_.size(), 1); \
148  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
149  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
150  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
151  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
152  }
153 
154 #define DEFINE_ONCE_TESTS(name, macro_base, level, log4cxx_level) \
155  TEST(RosConsole, name##Once) \
156  { \
157  TestAppender* appender = new TestAppender; \
158  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
159  macro_base##_ONCE("Testing %d %d %d", 1, 2, 3); \
160  ASSERT_EQ((int)appender->info_.size(), 1); \
161  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
162  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
163  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
164  } \
165  TEST(RosConsole, name##NamedOnce) \
166  { \
167  TestAppender* appender = new TestAppender; \
168  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
169  macro_base##_ONCE_NAMED("test", "Testing %d %d %d", 1, 2, 3); \
170  ASSERT_EQ((int)appender->info_.size(), 1); \
171  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
172  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
173  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
174  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
175  } \
176  TEST(RosConsole, name##StreamOnce) \
177  { \
178  TestAppender* appender = new TestAppender; \
179  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
180  macro_base##_STREAM_ONCE("Testing " << 1 << " " << 2 << " " << 3); \
181  ASSERT_EQ((int)appender->info_.size(), 1); \
182  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
183  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
184  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
185  } \
186  TEST(RosConsole, name##StreamOnceNamed) \
187  { \
188  TestAppender* appender = new TestAppender; \
189  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
190  macro_base##_STREAM_ONCE_NAMED("test", "Testing " << 1 << " " << 2 << " " << 3); \
191  ASSERT_EQ((int)appender->info_.size(), 1); \
192  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
193  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
194  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
195  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
196  }
197 
198 #define DEFINE_THROTTLE_TESTS(name, macro_base, level, log4cxx_level) \
199  TEST(RosConsole, name##Throttle) \
200  { \
201  TestAppender* appender = new TestAppender; \
202  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
203  macro_base##_THROTTLE(0.5, "Testing %d %d %d", 1, 2, 3); \
204  ASSERT_EQ((int)appender->info_.size(), 1); \
205  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
206  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
207  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
208  } \
209  TEST(RosConsole, name##NamedThrottle) \
210  { \
211  TestAppender* appender = new TestAppender; \
212  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
213  macro_base##_THROTTLE_NAMED(0.5, "test", "Testing %d %d %d", 1, 2, 3); \
214  ASSERT_EQ((int)appender->info_.size(), 1); \
215  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
216  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
217  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
218  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
219  } \
220  TEST(RosConsole, name##StreamThrottle) \
221  { \
222  TestAppender* appender = new TestAppender; \
223  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
224  macro_base##_STREAM_THROTTLE(0.5, "Testing " << 1 << " " << 2 << " " << 3); \
225  ASSERT_EQ((int)appender->info_.size(), 1); \
226  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
227  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
228  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
229  } \
230  TEST(RosConsole, name##StreamThrottleNamed) \
231  { \
232  TestAppender* appender = new TestAppender; \
233  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
234  macro_base##_STREAM_THROTTLE_NAMED(0.5, "test", "Testing " << 1 << " " << 2 << " " << 3); \
235  ASSERT_EQ((int)appender->info_.size(), 1); \
236  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
237  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
238  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
239  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
240  }
241 
242 #define DEFINE_FILTER_TESTS(name, macro_base, level, log4cxx_level) \
243  TEST(RosConsole, name##Filter) \
244  { \
245  TestAppender* appender = new TestAppender; \
246  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
247  macro_base##_FILTER(&g_filter, "Testing %d %d %d", 1, 2, 3); \
248  ASSERT_EQ((int)appender->info_.size(), 1); \
249  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
250  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
251  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
252  } \
253  TEST(RosConsole, name##NamedFilter) \
254  { \
255  TestAppender* appender = new TestAppender; \
256  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
257  macro_base##_FILTER_NAMED(&g_filter, "test", "Testing %d %d %d", 1, 2, 3); \
258  ASSERT_EQ((int)appender->info_.size(), 1); \
259  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
260  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
261  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
262  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
263  } \
264  TEST(RosConsole, name##StreamFilter) \
265  { \
266  TestAppender* appender = new TestAppender; \
267  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
268  macro_base##_STREAM_FILTER(&g_filter, "Testing " << 1 << " " << 2 << " " << 3); \
269  ASSERT_EQ((int)appender->info_.size(), 1); \
270  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
271  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
272  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
273  } \
274  TEST(RosConsole, name##StreamFilterNamed) \
275  { \
276  TestAppender* appender = new TestAppender; \
277  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
278  macro_base##_STREAM_FILTER_NAMED(&g_filter, "test", "Testing " << 1 << " " << 2 << " " << 3); \
279  ASSERT_EQ((int)appender->info_.size(), 1); \
280  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
281  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
282  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
283  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
284  }
285 
286 #define DEFINE_LEVEL_TESTS(name, macro_base, level, log4cxx_level) \
287  TEST(RosConsole, name) \
288  { \
289  TestAppender* appender = new TestAppender; \
290  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
291  macro_base("Testing %d %d %d", 1, 2, 3); \
292  ASSERT_EQ((int)appender->info_.size(), 1); \
293  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
294  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
295  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
296  } \
297  TEST(RosConsole, name##Named) \
298  { \
299  TestAppender* appender = new TestAppender; \
300  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
301  macro_base##_NAMED("test", "Testing %d %d %d", 1, 2, 3); \
302  ASSERT_EQ((int)appender->info_.size(), 1); \
303  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
304  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
305  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
306  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
307  } \
308  TEST(RosConsole, name##Stream) \
309  { \
310  TestAppender* appender = new TestAppender; \
311  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
312  macro_base##_STREAM("Testing " << 1 << " " << 2 << " " << 3); \
313  ASSERT_EQ((int)appender->info_.size(), 1); \
314  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
315  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
316  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
317  } \
318  TEST(RosConsole, name##StreamNamed) \
319  { \
320  TestAppender* appender = new TestAppender; \
321  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender( appender ); \
322  macro_base##_STREAM_NAMED("test", "Testing " << 1 << " " << 2 << " " << 3); \
323  ASSERT_EQ((int)appender->info_.size(), 1); \
324  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Testing 1 2 3"); \
325  EXPECT_EQ(appender->info_[0].level_, log4cxx_level); \
326  EXPECT_STREQ(appender->info_[0].logger_name_.c_str(), ROSCONSOLE_ROOT_LOGGER_NAME".rosconsole.test"); \
327  log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->removeAppender( appender ); \
328  } \
329  DEFINE_COND_TESTS(name, macro_base, level, log4cxx_level) \
330  DEFINE_ONCE_TESTS(name, macro_base, level, log4cxx_level) \
331  DEFINE_THROTTLE_TESTS(name, macro_base, level, log4cxx_level) \
332  DEFINE_FILTER_TESTS(name, macro_base, level, log4cxx_level)
333 
334 DEFINE_LEVEL_TESTS(debug, ROS_DEBUG, ros::console::levels::Debug, log4cxx::Level::getDebug())
335 DEFINE_LEVEL_TESTS(info, ROS_INFO, ros::console::levels::Info, log4cxx::Level::getInfo())
336 DEFINE_LEVEL_TESTS(warn, ROS_WARN, ros::console::levels::Warn, log4cxx::Level::getWarn())
337 DEFINE_LEVEL_TESTS(error, ROS_ERROR, ros::console::levels::Error, log4cxx::Level::getError())
338 DEFINE_LEVEL_TESTS(fatal, ROS_FATAL, ros::console::levels::Fatal, log4cxx::Level::getFatal())
339 
340 TEST(RosConsole, loggingLevels)
341 {
342  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
343 
344  TestAppender* appender = new TestAppender;
345  logger->addAppender( appender );
346 
347  int pre_count = 0;
348  int post_count = 0;
349 
350  {
351  logger->setLevel( log4cxx::Level::getInfo() );
352  pre_count = appender->info_.size();
353  ROS_DEBUG("test");
354  ROS_INFO("test");
355  ROS_WARN("test");
356  ROS_ERROR("test");
357  ROS_FATAL("test");
358  post_count = appender->info_.size();
359  EXPECT_EQ(post_count, pre_count + 4);
360 
361  logger->setLevel( log4cxx::Level::getWarn() );
362  pre_count = appender->info_.size();
363  ROS_DEBUG("test");
364  ROS_INFO("test");
365  ROS_WARN("test");
366  ROS_ERROR("test");
367  ROS_FATAL("test");
368  post_count = appender->info_.size();
369  EXPECT_EQ(post_count, pre_count + 3);
370 
371  logger->setLevel( log4cxx::Level::getError() );
372  pre_count = appender->info_.size();
373  ROS_DEBUG("test");
374  ROS_INFO("test");
375  ROS_WARN("test");
376  ROS_ERROR("test");
377  ROS_FATAL("test");
378  post_count = appender->info_.size();
379  EXPECT_EQ(post_count, pre_count + 2);
380 
381  logger->setLevel( log4cxx::Level::getFatal() );
382  pre_count = appender->info_.size();
383  ROS_DEBUG("test");
384  ROS_INFO("test");
385  ROS_WARN("test");
386  ROS_ERROR("test");
387  ROS_FATAL("test");
388  post_count = appender->info_.size();
389  EXPECT_EQ(post_count, pre_count + 1);
390 
391  logger->setLevel( log4cxx::Level::getOff() );
392  pre_count = appender->info_.size();
393  ROS_DEBUG("test");
394  ROS_INFO("test");
395  ROS_WARN("test");
396  ROS_ERROR("test");
397  ROS_FATAL("test");
398  post_count = appender->info_.size();
399  EXPECT_EQ(post_count, pre_count);
400  }
401 
402  {
403  logger->setLevel( log4cxx::Level::getInfo() );
404  pre_count = appender->info_.size();
405  ROS_DEBUG_STREAM("test");
406  ROS_INFO_STREAM("test");
407  ROS_WARN_STREAM("test");
408  ROS_ERROR_STREAM("test");
409  ROS_FATAL_STREAM("test");
410  post_count = appender->info_.size();
411  EXPECT_EQ(post_count, pre_count + 4);
412 
413  logger->setLevel( log4cxx::Level::getWarn() );
414  pre_count = appender->info_.size();
415  ROS_DEBUG_STREAM("test");
416  ROS_INFO_STREAM("test");
417  ROS_WARN_STREAM("test");
418  ROS_ERROR_STREAM("test");
419  ROS_FATAL_STREAM("test");
420  post_count = appender->info_.size();
421  EXPECT_EQ(post_count, pre_count + 3);
422 
423  logger->setLevel( log4cxx::Level::getError() );
424  pre_count = appender->info_.size();
425  ROS_DEBUG_STREAM("test");
426  ROS_INFO_STREAM("test");
427  ROS_WARN_STREAM("test");
428  ROS_ERROR_STREAM("test");
429  ROS_FATAL_STREAM("test");
430  post_count = appender->info_.size();
431  EXPECT_EQ(post_count, pre_count + 2);
432 
433  logger->setLevel( log4cxx::Level::getFatal() );
434  pre_count = appender->info_.size();
435  ROS_DEBUG_STREAM("test");
436  ROS_INFO_STREAM("test");
437  ROS_WARN_STREAM("test");
438  ROS_ERROR_STREAM("test");
439  ROS_FATAL_STREAM("test");
440  post_count = appender->info_.size();
441  EXPECT_EQ(post_count, pre_count + 1);
442 
443  logger->setLevel( log4cxx::Level::getOff() );
444  pre_count = appender->info_.size();
445  ROS_DEBUG_STREAM("test");
446  ROS_INFO_STREAM("test");
447  ROS_WARN_STREAM("test");
448  ROS_ERROR_STREAM("test");
449  ROS_FATAL_STREAM("test");
450  post_count = appender->info_.size();
451  EXPECT_EQ(post_count, pre_count);
452  }
453 
454  {
455  logger->setLevel( log4cxx::Level::getInfo() );
456  pre_count = appender->info_.size();
457  ROS_DEBUG_NAMED("test_name", "test");
458  ROS_INFO_NAMED("test_name", "test");
459  ROS_WARN_NAMED("test_name", "test");
460  ROS_ERROR_NAMED("test_name", "test");
461  ROS_FATAL_NAMED("test_name", "test");
462  post_count = appender->info_.size();
463  EXPECT_EQ(post_count, pre_count + 4);
464 
465  logger->setLevel( log4cxx::Level::getWarn() );
466  pre_count = appender->info_.size();
467  ROS_DEBUG_NAMED("test_name", "test");
468  ROS_INFO_NAMED("test_name", "test");
469  ROS_WARN_NAMED("test_name", "test");
470  ROS_ERROR_NAMED("test_name", "test");
471  ROS_FATAL_NAMED("test_name", "test");
472  post_count = appender->info_.size();
473  EXPECT_EQ(post_count, pre_count + 3);
474 
475  logger->setLevel( log4cxx::Level::getError() );
476  pre_count = appender->info_.size();
477  ROS_DEBUG_NAMED("test_name", "test");
478  ROS_INFO_NAMED("test_name", "test");
479  ROS_WARN_NAMED("test_name", "test");
480  ROS_ERROR_NAMED("test_name", "test");
481  ROS_FATAL_NAMED("test_name", "test");
482  post_count = appender->info_.size();
483  EXPECT_EQ(post_count, pre_count + 2);
484 
485  logger->setLevel( log4cxx::Level::getFatal() );
486  pre_count = appender->info_.size();
487  ROS_DEBUG_NAMED("test_name", "test");
488  ROS_INFO_NAMED("test_name", "test");
489  ROS_WARN_NAMED("test_name", "test");
490  ROS_ERROR_NAMED("test_name", "test");
491  ROS_FATAL_NAMED("test_name", "test");
492  post_count = appender->info_.size();
493  EXPECT_EQ(post_count, pre_count + 1);
494 
495  logger->setLevel( log4cxx::Level::getOff() );
496  pre_count = appender->info_.size();
497  ROS_DEBUG_NAMED("test_name", "test");
498  ROS_INFO_NAMED("test_name", "test");
499  ROS_WARN_NAMED("test_name", "test");
500  ROS_ERROR_NAMED("test_name", "test");
501  ROS_FATAL_NAMED("test_name", "test");
502  post_count = appender->info_.size();
503  EXPECT_EQ(post_count, pre_count);
504  }
505 
506  {
507  logger->setLevel( log4cxx::Level::getInfo() );
508  pre_count = appender->info_.size();
509  ROS_DEBUG_STREAM_NAMED("test_name", "test");
510  ROS_INFO_STREAM_NAMED("test_name", "test");
511  ROS_WARN_STREAM_NAMED("test_name", "test");
512  ROS_ERROR_STREAM_NAMED("test_name", "test");
513  ROS_FATAL_STREAM_NAMED("test_name", "test");
514  post_count = appender->info_.size();
515  EXPECT_EQ(post_count, pre_count + 4);
516 
517  logger->setLevel( log4cxx::Level::getWarn() );
518  pre_count = appender->info_.size();
519  ROS_DEBUG_STREAM_NAMED("test_name", "test");
520  ROS_INFO_STREAM_NAMED("test_name", "test");
521  ROS_WARN_STREAM_NAMED("test_name", "test");
522  ROS_ERROR_STREAM_NAMED("test_name", "test");
523  ROS_FATAL_STREAM_NAMED("test_name", "test");
524  post_count = appender->info_.size();
525  EXPECT_EQ(post_count, pre_count + 3);
526 
527  logger->setLevel( log4cxx::Level::getError() );
528  pre_count = appender->info_.size();
529  ROS_DEBUG_STREAM_NAMED("test_name", "test");
530  ROS_INFO_STREAM_NAMED("test_name", "test");
531  ROS_WARN_STREAM_NAMED("test_name", "test");
532  ROS_ERROR_STREAM_NAMED("test_name", "test");
533  ROS_FATAL_STREAM_NAMED("test_name", "test");
534  post_count = appender->info_.size();
535  EXPECT_EQ(post_count, pre_count + 2);
536 
537  logger->setLevel( log4cxx::Level::getFatal() );
538  pre_count = appender->info_.size();
539  ROS_DEBUG_STREAM_NAMED("test_name", "test");
540  ROS_INFO_STREAM_NAMED("test_name", "test");
541  ROS_WARN_STREAM_NAMED("test_name", "test");
542  ROS_ERROR_STREAM_NAMED("test_name", "test");
543  ROS_FATAL_STREAM_NAMED("test_name", "test");
544  post_count = appender->info_.size();
545  EXPECT_EQ(post_count, pre_count + 1);
546 
547  logger->setLevel( log4cxx::Level::getOff() );
548  pre_count = appender->info_.size();
549  ROS_DEBUG_STREAM_NAMED("test_name", "test");
550  ROS_INFO_STREAM_NAMED("test_name", "test");
551  ROS_WARN_STREAM_NAMED("test_name", "test");
552  ROS_ERROR_STREAM_NAMED("test_name", "test");
553  ROS_FATAL_STREAM_NAMED("test_name", "test");
554  post_count = appender->info_.size();
555  EXPECT_EQ(post_count, pre_count);
556  }
557 
558  logger->removeAppender( appender );
559 }
560 
561 TEST(RosConsole, changingLevel)
562 {
563  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
564 
565  TestAppender* appender = new TestAppender;
566  logger->addAppender( appender );
567 
568  logger->setLevel( log4cxx::Level::getError() );
570  {
572  }
573 
574  EXPECT_EQ((int)appender->info_.size(), 2);
575 
576  logger->removeAppender( appender );
577 
578  logger->setLevel( log4cxx::Level::getDebug() );
579 }
580 
581 TEST(RosConsole, changingLoggerLevel)
582 {
583  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
584 
585  TestAppender* appender = new TestAppender;
586  logger->addAppender( appender );
587 
588  logger->setLevel(log4cxx::Level::getDebug());
591 
592  logger->setLevel(log4cxx::Level::getInfo());
595 
596  logger->setLevel(log4cxx::Level::getWarn());
599 
600  logger->setLevel(log4cxx::Level::getError());
603 
604  logger->setLevel(log4cxx::Level::getFatal());
607 
608  EXPECT_EQ((int)appender->info_.size(), 5);
609 
610  logger->removeAppender( appender );
611 
612  logger->setLevel( log4cxx::Level::getDebug() );
613 }
614 
615 TEST(RosConsole, longPrintfStyleOutput)
616 {
617  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
618 
619  TestAppender* appender = new TestAppender;
620  logger->addAppender( appender );
621 
622  std::stringstream ss;
623  for (int i = 0; i < 100000; ++i )
624  {
625  ss << 'a';
626  }
627 
628  ROS_INFO("%s", ss.str().c_str());
629 
630  ASSERT_EQ((int)appender->info_.size(), 1);
631  EXPECT_STREQ(appender->info_[0].message_.c_str(), ss.str().c_str());
632 
633  logger->removeAppender( appender );
634 
635  logger->setLevel( log4cxx::Level::getDebug() );
636 }
637 
638 TEST(RosConsole, throwingAppender)
639 {
640  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
641 
643  logger->addAppender( appender );
644 
645  try
646  {
647  ROS_INFO("Hello there");
648  }
649  catch (std::exception& e)
650  {
651  FAIL();
652  }
653 
654  logger->removeAppender( appender );
655  logger->setLevel( log4cxx::Level::getDebug() );
656 }
657 
658 void onceFunc()
659 {
661 }
662 
663 TEST(RosConsole, once)
664 {
665  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
666 
667  TestAppender* appender = new TestAppender;
668  logger->addAppender(appender);
669 
670  onceFunc();
671  onceFunc();
672 
673  EXPECT_EQ(appender->info_.size(), 1ULL);
674 
675  logger->removeAppender(appender);
676 }
677 
679 {
681 }
682 
683 TEST(RosConsole, throttle)
684 {
685  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
686 
687  TestAppender* appender = new TestAppender;
688  logger->addAppender(appender);
689 
690  ros::Time start = ros::Time::now();
691  while (ros::Time::now() <= start + ros::Duration(0.5))
692  {
693  throttleFunc();
694  ros::Duration(0.01).sleep();
695  }
696 
697  throttleFunc();
698 
699  EXPECT_EQ(appender->info_.size(), 2ULL);
700 
701  logger->removeAppender(appender);
702 }
703 
705 {
707 }
708 
710 {
712 }
713 
714 TEST(RosConsole, delayedThrottle)
715 {
716  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
717 
718  TestAppender* appender = new TestAppender;
719  logger->addAppender(appender);
720 
721  ros::Time start = ros::Time::now();
722  while (ros::Time::now() <= start + ros::Duration(0.4))
723  {
725  ros::Duration(0.01).sleep();
726  }
727 
728  EXPECT_EQ(appender->info_.size(), 0ULL);
729 
730  const int pre_count = appender->info_.size();
731  start = ros::Time::now();
732  while (ros::Time::now() <= start + ros::Duration(0.6))
733  {
735  ros::Duration(0.01).sleep();
736  }
737 
738  const int post_count = appender->info_.size();
739 
740  EXPECT_EQ(post_count, pre_count + 1);
741 
742  logger->removeAppender(appender);
743 }
744 
745 
747 {
749 }
750 
751 TEST(RosConsole, onceStream)
752 {
753  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
754 
755  TestAppender* appender = new TestAppender;
756  logger->addAppender(appender);
757 
758  onceStreamFunc();
759  onceStreamFunc();
760 
761  EXPECT_EQ(appender->info_.size(), 1ULL);
762 
763  logger->removeAppender(appender);
764 }
765 
767 {
769 }
770 
771 TEST(RosConsole, throttleStream)
772 {
773  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
774 
775  TestAppender* appender = new TestAppender;
776  logger->addAppender(appender);
777 
778  ros::Time start = ros::Time::now();
779  while (ros::Time::now() <= start + ros::Duration(0.5))
780  {
782  ros::Duration(0.01).sleep();
783  }
784 
786 
787  EXPECT_EQ(appender->info_.size(), 2ULL);
788 
789  logger->removeAppender(appender);
790 }
791 
793 {
795 }
796 
798 {
800 }
801 
802 TEST(RosConsole, delayedStreamThrottle)
803 {
804  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
805 
806  TestAppender* appender = new TestAppender;
807  logger->addAppender(appender);
808 
809  ros::Time start = ros::Time::now();
810  while (ros::Time::now() <= start + ros::Duration(0.4))
811  {
813  ros::Duration(0.01).sleep();
814  }
815 
816  EXPECT_EQ(appender->info_.size(), 0ULL);
817 
818  const int pre_count = appender->info_.size();
819  start = ros::Time::now();
820  while (ros::Time::now() <= start + ros::Duration(0.6))
821  {
823  ros::Duration(0.01).sleep();
824  }
825 
826  const int post_count = appender->info_.size();
827 
828  EXPECT_EQ(post_count, pre_count + 1);
829 
830  logger->removeAppender(appender);
831 }
832 
833 TEST(RosConsole, basicFilter)
834 {
835  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
836 
837  TestAppender* appender = new TestAppender;
838  logger->addAppender(appender);
839 
840  BasicFilter trueFilter(true), falseFilter(false);
843 
844  ASSERT_EQ(appender->info_.size(), 1ULL);
845  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Hello");
846 
847  logger->removeAppender(appender);
848 }
849 
850 TEST(RosConsole, basicFilterStream)
851 {
852  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
853 
854  TestAppender* appender = new TestAppender;
855  logger->addAppender(appender);
856 
857  BasicFilter trueFilter(true), falseFilter(false);
860 
861  ASSERT_EQ(appender->info_.size(), 1ULL);
862  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Hello");
863 
864  logger->removeAppender(appender);
865 }
866 
868 {
869  AdvancedFilter(bool enabled)
870  : enabled_(enabled)
871  , count_(0)
872  {}
873 
875  inline virtual bool isEnabled(ros::console::FilterParams& params)
876  {
877  fprintf(stderr, "%s %s:%d:%s\n", params.message, params.file, params.line, params.function);
878  ++count_;
879  return enabled_;
880  }
881 
882  bool enabled_;
883  int count_;
884 };
885 
886 TEST(RosConsole, advancedFilter)
887 {
888  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
889 
890  TestAppender* appender = new TestAppender;
891  logger->addAppender(appender);
892 
893  AdvancedFilter trueFilter(true), falseFilter(false);
896 
897  ASSERT_EQ(appender->info_.size(), 1ULL);
898  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Hello");
899  EXPECT_EQ(trueFilter.count_, 1);
900  EXPECT_EQ(falseFilter.count_, 1);
901 
902  logger->removeAppender(appender);
903 }
904 
905 TEST(RosConsole, advancedFilterStream)
906 {
907  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
908 
909  TestAppender* appender = new TestAppender;
910  logger->addAppender(appender);
911 
912  AdvancedFilter trueFilter(true), falseFilter(false);
915 
916  ASSERT_EQ(appender->info_.size(), 1ULL);
917  EXPECT_STREQ(appender->info_[0].message_.c_str(), "Hello");
918  EXPECT_EQ(trueFilter.count_, 1);
919  EXPECT_EQ(falseFilter.count_, 1);
920 
921  logger->removeAppender(appender);
922 }
923 
925 {
927  inline virtual bool isEnabled(ros::console::FilterParams& params)
928  {
929  params.out_message = "haha";
931  return true;
932  }
933 };
934 
935 TEST(RosConsole, changeFilter)
936 {
937  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
938 
939  TestAppender* appender = new TestAppender;
940  logger->addAppender(appender);
941 
942  ChangeFilter filter;
944 
945  ASSERT_EQ(appender->info_.size(), 1ULL);
946  EXPECT_STREQ(appender->info_[0].message_.c_str(), "haha");
947  EXPECT_EQ(appender->info_[0].level_, log4cxx::Level::getError());
948 
949  logger->removeAppender(appender);
950 }
951 
952 TEST(RosConsole, changeFilterStream)
953 {
954  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME);
955 
956  TestAppender* appender = new TestAppender;
957  logger->addAppender(appender);
958 
959  ChangeFilter filter;
961 
962  ASSERT_EQ(appender->info_.size(), 1ULL);
963  EXPECT_STREQ(appender->info_[0].message_.c_str(), "haha");
964  EXPECT_EQ(appender->info_[0].level_, log4cxx::Level::getError());
965 
966  logger->removeAppender(appender);
967 }
968 
969 TEST(RosConsole, formatToBufferInitialZero)
970 {
972  size_t size = 0;
973  ros::console::formatToBuffer(buffer, size, "Hello World %d", 5);
974  EXPECT_EQ(size, 14U);
975  EXPECT_STREQ(buffer.get(), "Hello World 5");
976 }
977 
978 TEST(RosConsole, formatToBufferInitialLargerThanFormat)
979 {
980  boost::shared_array<char> buffer(new char[30]);
981  size_t size = 30;
982  ros::console::formatToBuffer(buffer, size, "Hello World %d", 5);
983  EXPECT_EQ(size, 30U);
984  EXPECT_STREQ(buffer.get(), "Hello World 5");
985 }
986 
987 TEST(RosConsole, formatToString)
988 {
989  std::string str = ros::console::formatToString("Hello World %d", 5);
990  EXPECT_STREQ(str.c_str(), "Hello World 5");
991 }
992 
993 int main(int argc, char **argv)
994 {
995  testing::InitGoogleTest(&argc, argv);
996  ros::Time::init();
997 
999  log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->removeAllAppenders();
1000  log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug());
1001  log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->setLevel(log4cxx::Level::getDebug());
1002 
1003  return RUN_ALL_TESTS();
1004 }
#define ROS_LOG_THROTTLE(period, level, name,...)
Log to a given named logger at a given verbosity level, limited to a specific rate of printing...
Definition: console.h:446
#define ROS_FATAL(...)
virtual bool isEnabled()
Returns whether or not the log statement should be printed. Called before the log arguments are evalu...
Definition: console.h:234
#define ROS_INFO_NAMED(name,...)
AdvancedFilter(bool enabled)
Definition: utest.cpp:869
virtual void close()
Definition: utest.cpp:67
#define ROS_DEBUG_STREAM_NAMED(name, args)
ROSCONSOLE_DECL void notifyLoggerLevelsChanged()
Tells the system that a logger&#39;s level has changed.
Definition: rosconsole.cpp:688
Base-class for filters. Filters allow full user-defined control over whether or not a message should ...
Definition: console.h:226
#define DEFINE_LEVEL_TESTS(name, macro_base, level, log4cxx_level)
Definition: utest.cpp:286
#define ROS_ERROR_STREAM_NAMED(name, args)
Parameter structure passed to FilterBase::isEnabled(...);. Includes both input and output parameters...
Definition: console.h:189
#define ROS_WARN_NAMED(name,...)
virtual void close()
Definition: utest.cpp:84
bool sleep() const
#define ROS_LOG_STREAM_THROTTLE(period, level, name, args)
Log to a given named logger at a given verbosity level, limited to a specific rate of printing...
Definition: console.h:467
const char * message
[input] The formatted message that will be output
Definition: console.h:195
#define ROS_INFO_STREAM_NAMED(name, args)
#define ROSCONSOLE_AUTOINIT
Initializes the rosconsole library. Usually unnecessary to call directly.
Definition: console.h:322
virtual void append(const log4cxx::spi::LoggingEventPtr &, log4cxx::helpers::Pool &)
Definition: utest.cpp:79
#define ROS_WARN(...)
ROSCONSOLE_DECL std::string formatToString(const char *fmt,...)
Definition: rosconsole.cpp:497
#define ROSCONSOLE_ROOT_LOGGER_NAME
Definition: console.h:297
std::string out_message
[output] If set, writes this message instead of the original
Definition: console.h:202
Level level
[input/output] Severity level. If changed, uses the new level
Definition: console.h:199
BasicFilter(bool enabled)
Definition: utest.cpp:95
std::string logger_name_
Definition: thread_test.cpp:48
#define ROS_LOG_STREAM_ONCE(level, name, args)
Log to a given named logger at a given verbosity level, only the first time it is hit when enabled...
Definition: console.h:427
#define ROS_DEBUG_NAMED(name,...)
#define ROS_FATAL_STREAM(args)
#define ROS_FATAL_STREAM_NAMED(name, args)
void delayedThrottleStreamFunc2()
Definition: utest.cpp:797
#define ROS_INFO(...)
const char * file
[input] File the message came from
Definition: console.h:192
log4cxx::LevelPtr level_
Definition: thread_test.cpp:46
std::vector< Info > V_Info
Definition: utest.cpp:52
static void init()
int main(int argc, char **argv)
Definition: utest.cpp:993
const char * function
[input] Function the message came from
Definition: console.h:194
virtual bool requiresLayout() const
Definition: utest.cpp:70
void delayedThrottleFunc2()
Definition: utest.cpp:709
void throttleFunc()
Definition: utest.cpp:678
virtual bool requiresLayout() const
Definition: utest.cpp:87
#define ROS_LOG_DELAYED_THROTTLE(period, level, name,...)
Log to a given named logger at a given verbosity level, limited to a specific rate of printing...
Definition: console.h:487
void throttleStreamFunc()
Definition: utest.cpp:766
#define ROS_WARN_STREAM(args)
BasicFilter g_filter(true)
#define ROS_DEBUG_STREAM(args)
void delayedThrottleFunc()
Definition: utest.cpp:704
virtual void append(const log4cxx::spi::LoggingEventPtr &event, log4cxx::helpers::Pool &)
Definition: utest.cpp:57
virtual bool isEnabled(ros::console::FilterParams &params)
Returns whether or not the log statement should be printed. Called once the message has been formatte...
Definition: utest.cpp:927
virtual bool isEnabled()
Returns whether or not the log statement should be printed. Called before the log arguments are evalu...
Definition: utest.cpp:99
#define ROS_LOG(level, name,...)
Log to a given named logger at a given verbosity level, with printf-style formatting.
Definition: console.h:561
void onceStreamFunc()
Definition: utest.cpp:746
#define ROS_INFO_STREAM(args)
void onceFunc()
Definition: utest.cpp:658
bool enabled_
Definition: utest.cpp:882
void delayedThrottleStreamFunc()
Definition: utest.cpp:792
#define ROS_LOG_FILTER(filter, level, name,...)
Log to a given named logger at a given verbosity level, with user-defined filtering, with printf-style formatting.
Definition: console.h:528
#define ROS_FATAL_NAMED(name,...)
int line
[input] Line the message came from
Definition: console.h:193
#define ROS_ERROR_NAMED(name,...)
static Time now()
#define ROS_LOG_STREAM_FILTER(filter, level, name, args)
Log to a given named logger at a given verbosity level, with user-defined filtering, with stream-style formatting.
Definition: console.h:545
#define ROS_LOG_STREAM_DELAYED_THROTTLE(period, level, name, args)
Log to a given named logger at a given verbosity level, limited to a specific rate of printing and po...
Definition: console.h:508
#define ROS_LOG_ONCE(level, name,...)
Log to a given named logger at a given verbosity level, only the first time it is hit when enabled...
Definition: console.h:408
#define ROS_ERROR_STREAM(args)
TEST(RosConsole, loggingLevels)
Definition: utest.cpp:340
#define ROS_ERROR(...)
virtual bool isEnabled(ros::console::FilterParams &params)
Returns whether or not the log statement should be printed. Called once the message has been formatte...
Definition: utest.cpp:875
#define ROSCONSOLE_DEFAULT_NAME
Definition: console.h:299
std::string message_
Definition: thread_test.cpp:47
ROSCONSOLE_DECL void formatToBuffer(boost::shared_array< char > &buffer, size_t &buffer_size, const char *fmt,...)
Definition: rosconsole.cpp:487
#define ROS_WARN_STREAM_NAMED(name, args)
#define ROS_DEBUG(...)


rosconsole
Author(s): Josh Faust
autogenerated on Sun Feb 3 2019 03:29:44