rosconsole.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 the 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 // Author: Josh Faust
31 
32 #if defined(__APPLE__) && defined(__GNUC__) && defined(__llvm__) && !defined(__clang__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
33 #error This code is known to provoke a compiler crash with llvm-gcc 4.2. You will have better luck with clang++. See code.ros.org/trac/ros/ticket/3626
34 #endif
35 
36 #include "ros/console.h"
37 #include "ros/console_impl.h"
38 #include "ros/assert.h"
39 #include <ros/time.h>
40 
41 #include <boost/thread.hpp>
42 #include <boost/shared_array.hpp>
43 #include <boost/regex.hpp>
44 #include <boost/make_shared.hpp>
45 #include <boost/date_time/posix_time/posix_time.hpp>
46 
47 #include <cstdarg>
48 #include <cstdlib>
49 #include <cstdio>
50 #include <memory>
51 #include <cstring>
52 #include <stdexcept>
53 
54 // declare interface for rosconsole implementations
55 namespace ros
56 {
57 namespace console
58 {
59 
60 bool g_initialized = false;
61 bool g_shutting_down = false;
62 boost::mutex g_init_mutex;
63 
64 #ifdef ROSCONSOLE_BACKEND_LOG4CXX
65 log4cxx::LevelPtr g_level_lookup[levels::Count] =
66 {
67  log4cxx::Level::getDebug(),
68  log4cxx::Level::getInfo(),
69  log4cxx::Level::getWarn(),
70  log4cxx::Level::getError(),
71  log4cxx::Level::getFatal(),
72 };
73 #endif
74 std::string g_last_error_message = "Unknown Error";
75 
76 #ifdef _WIN32
77  #define COLOR_NORMAL ""
78  #define COLOR_RED ""
79  #define COLOR_GREEN ""
80  #define COLOR_YELLOW ""
81 #else
82  #define COLOR_NORMAL "\033[0m"
83  #define COLOR_RED "\033[31m"
84  #define COLOR_GREEN "\033[32m"
85  #define COLOR_YELLOW "\033[33m"
86 #endif
87 const char* g_format_string = "[${severity}] [${time}]: ${message}";
88 
91 bool g_color = true;
92 
93 typedef std::map<std::string, std::string> M_string;
95 
96 void setFixedFilterToken(const std::string& key, const std::string& val)
97 {
98  g_extra_fixed_tokens[key] = val;
99 }
100 
101 struct FixedToken : public Token
102 {
103  FixedToken(const std::string& str)
104  : str_(str)
105  {}
106 
107  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char*, int)
108  {
109  return str_.c_str();
110  }
111 
112  std::string str_;
113 };
114 
115 struct FixedMapToken : public Token
116 {
117  FixedMapToken(const std::string& str)
118  : str_(str)
119  {}
120 
121  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char*, int)
122  {
123  M_string::iterator it = g_extra_fixed_tokens.find(str_);
124  if (it == g_extra_fixed_tokens.end())
125  {
126  return ("${" + str_ + "}").c_str();
127  }
128 
129  return it->second.c_str();
130  }
131 
132  std::string str_;
133 };
134 
135 struct PlaceHolderToken : public Token
136 {
137  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char*, int)
138  {
139  return "PLACEHOLDER";
140  }
141 };
142 
143 struct SeverityToken : public Token
144 {
145  virtual std::string getString(void*, ::ros::console::Level level, const char* str, const char* file, const char* function, int line)
146  {
147  (void)str;
148  (void)file;
149  (void)function;
150  (void)line;
151  if (level == levels::Fatal)
152  {
153  return "FATAL";
154  }
155  else if (level == levels::Error)
156  {
157  return "ERROR";
158  }
159  else if (level == levels::Warn)
160  {
161  return "WARN";
162  }
163  else if (level == levels::Info)
164  {
165  return "INFO";
166  }
167  else if (level == levels::Debug)
168  {
169  return "DEBUG";
170  }
171 
172  return "UNKNO";
173  }
174 };
175 
176 struct MessageToken : public Token
177 {
178  virtual std::string getString(void*, ::ros::console::Level, const char* str, const char*, const char*, int)
179  {
180  return str;
181  }
182 };
183 
184 struct TimeToken : public Token
185 {
186  explicit TimeToken(const std::string &format) : format_(format) {};
187 
188  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char*, int)
189  {
190  std::stringstream ss;
191 
192  if (format_.empty())
193  {
194  ss << ros::WallTime::now();
195  }
196  else
197  {
198  boost::posix_time::time_facet *facet = new boost::posix_time::time_facet();
199  facet->format(format_.c_str());
200  ss.imbue(std::locale(std::locale::classic(), facet));
201  ss << ros::WallTime::now().toBoost();
202  }
203 
205  {
206  ss << ", ";
207 
208  if (format_.empty())
209  {
210  ss << ros::Time::now();
211  }
212  else
213  {
214  ss << ros::Time::now().toBoost();
215  }
216  }
217  return ss.str();
218  }
219 
220  const std::string format_;
221 };
222 
223 struct WallTimeToken : public Token
224 {
225  explicit WallTimeToken(const std::string &format) : format_(format) {};
226 
227  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char*, int)
228  {
229  std::stringstream ss;
230 
231  if (format_.empty())
232  {
233  ss << ros::WallTime::now();
234  }
235  else
236  {
237  boost::posix_time::time_facet* facet = new boost::posix_time::time_facet();
238  facet->format(format_.c_str());
239  ss.imbue(std::locale(std::locale::classic(), facet));
240  ss << ros::WallTime::now().toBoost();
241  }
242 
243  return ss.str();
244  }
245 
246  const std::string format_;
247 };
248 
249 struct ThreadToken : public Token
250 {
251  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char*, int)
252  {
253  std::stringstream ss;
254  ss << boost::this_thread::get_id();
255  return ss.str();
256  }
257 };
258 
259 struct LoggerToken : public Token
260 {
261  virtual std::string getString(void* logger_handle, ::ros::console::Level level, const char* str, const char* file, const char* function, int line)
262  {
263  (void)level;
264  (void)str;
265  (void)file;
266  (void)function;
267  (void)line;
269  }
270 };
271 
272 struct FileToken : public Token
273 {
274  virtual std::string getString(void*, ::ros::console::Level, const char*, const char* file, const char*, int)
275  {
276  return file;
277  }
278 };
279 
280 struct FunctionToken : public Token
281 {
282  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char* function, int)
283  {
284  return function;
285  }
286 };
287 
288 struct LineToken : public Token
289 {
290  virtual std::string getString(void*, ::ros::console::Level, const char*, const char*, const char*, int line)
291  {
292  std::stringstream ss;
293  ss << line;
294  return ss.str();
295  }
296 };
297 
298 TokenPtr createTokenFromType(const std::string& type)
299 {
300  if (type == "severity")
301  {
302  return TokenPtr(boost::make_shared<SeverityToken>());
303  }
304  else if (type == "message")
305  {
306  return TokenPtr(boost::make_shared<MessageToken>());
307  }
308  else if (type == "time" || strncmp(type.c_str(), std::string("time:").c_str(), std::string("time:").size()) == 0)
309  {
310  std::string format;
311 
312  std::size_t found = type.find(':');
313  if (found != std::string::npos)
314  {
315  format = type.substr(found + 1, type.size());
316  }
317 
318  return TokenPtr(boost::make_shared<TimeToken>(format));
319  }
320  else if (type == "walltime" || strncmp(type.c_str(), std::string("walltime:").c_str(), std::string("walltime:").size()) == 0)
321  {
322  std::string format;
323 
324  std::size_t found = type.find(':');
325  if (found != std::string::npos)
326  {
327  format = type.substr(found + 1, type.size());
328  }
329 
330  return TokenPtr(boost::make_shared<WallTimeToken>(format));
331  }
332  else if (type == "thread")
333  {
334  return TokenPtr(boost::make_shared<ThreadToken>());
335  }
336  else if (type == "logger")
337  {
338  return TokenPtr(boost::make_shared<LoggerToken>());
339  }
340  else if (type == "file")
341  {
342  return TokenPtr(boost::make_shared<FileToken>());
343  }
344  else if (type == "line")
345  {
346  return TokenPtr(boost::make_shared<LineToken>());
347  }
348  else if (type == "function")
349  {
350  return TokenPtr(boost::make_shared<FunctionToken>());
351  }
352 
353  return TokenPtr(boost::make_shared<FixedMapToken>(type));
354 }
355 
356 void Formatter::init(const char* fmt)
357 {
358  format_ = fmt;
359 
360  boost::regex e("\\$\\{([^\\}]+)\\}");
361  boost::match_results<std::string::const_iterator> results;
362  std::string::const_iterator start, end;
363  start = format_.begin();
364  end = format_.end();
365  bool matched_once = false;
366  std::string last_suffix;
367  while (boost::regex_search(start, end, results, e))
368  {
369 #if 0
370  for (size_t i = 0; i < results.size(); ++i)
371  {
372  std::cout << i << "|" << results.prefix() << "|" << results[i] << "|" << results.suffix() << std::endl;
373  }
374 #endif
375 
376  std::string token = results[1];
377  last_suffix = results.suffix();
378  tokens_.push_back(TokenPtr(boost::make_shared<FixedToken>(results.prefix())));
379  tokens_.push_back(createTokenFromType(token));
380 
381  start = results[0].second;
382  matched_once = true;
383  }
384 
385  if (matched_once)
386  {
387  tokens_.push_back(TokenPtr(boost::make_shared<FixedToken>(last_suffix)));
388  }
389  else
390  {
391  tokens_.push_back(TokenPtr(boost::make_shared<FixedToken>(format_)));
392  }
393 }
394 
395 void Formatter::print(void* logger_handle, ::ros::console::Level level, const char* str, const char* file, const char* function, int line)
396 {
397  // print in red to stderr if level doesn't match any of the predefined ones
398  const char* color = COLOR_RED;
399  FILE* f = stderr;
400 
401  if (level == levels::Fatal)
402  {
403  color = COLOR_RED;
404  }
405  else if (level == levels::Error)
406  {
407  color = COLOR_RED;
408  }
409  else if (level == levels::Warn)
410  {
411  color = COLOR_YELLOW;
412  }
413  else if (level == levels::Info)
414  {
415  color = COLOR_NORMAL;
416  f = stdout;
417  }
418  else if (level == levels::Debug)
419  {
420  color = COLOR_GREEN;
421  f = stdout;
422  }
423 
424  std::stringstream ss;
425  if (g_color)
426  {
427  ss << color;
428  }
429  ss << getTokenStrings(logger_handle, level, str, file, function, line);
430  if (g_color)
431  {
432  ss << COLOR_NORMAL;
433  }
434 
435  fprintf(f, "%s\n", ss.str().c_str());
436 
437  if (g_force_stdout_line_buffered && f == stdout)
438  {
439  int flush_result = fflush(f);
440  if (flush_result != 0 && !g_stdout_flush_failure_reported)
441  {
443  fprintf(stderr, "Error: failed to perform fflush on stdout, fflush return code is %d\n", flush_result);
444  }
445  }
446 }
447 
448 std::string
449 Formatter::getTokenStrings(void *logger_handle, ::ros::console::Level level, const char *str, const char *file,
450  const char *function, int line) const
451 {
452  std::stringstream ss;
453 
454  for (V_Token::const_iterator it = tokens_.begin(); it != tokens_.end(); ++it)
455  {
456  ss << (*it)->getString(logger_handle, level, str, file, function, line);
457  }
458 
459  return ss.str();
460 }
461 
463 
464 
465 void _print(void* logger_handle, ::ros::console::Level level, const char* str, const char* file, const char* function, int line)
466 {
467  g_formatter.print(logger_handle, level, str, file, function, line);
468 }
469 
471 {
472  boost::mutex::scoped_lock lock(g_init_mutex);
473 
474  if (!g_initialized)
475  {
476  // Check for the format string environment variable
477  char* format_string = NULL;
478 #ifdef _MSC_VER
479  _dupenv_s(&format_string, NULL, "ROSCONSOLE_FORMAT");
480 #else
481  format_string = getenv("ROSCONSOLE_FORMAT");
482 #endif
483  if (format_string)
484  {
485  g_format_string = format_string;
486  }
487 
491 
492  std::string line_buffered;
493  if (get_environment_variable(line_buffered, "ROSCONSOLE_STDOUT_LINE_BUFFERED"))
494  {
495  if (line_buffered == "1")
496  {
498  }
499  else if (line_buffered != "0")
500  {
501  fprintf(stderr, "Warning: unexpected value %s specified for ROSCONSOLE_STDOUT_LINE_BUFFERED. Default value 0 "
502  "will be used. Valid values are 1 or 0.\n", line_buffered.c_str());
503  }
504  }
505 
506  std::string no_color;
507  if (get_environment_variable(no_color, "NO_COLOR"))
508  {
509  g_color = false;
510  }
511 
513  g_initialized = true;
514  }
515 }
516 
517 void vformatToBuffer(boost::shared_array<char>& buffer, size_t& buffer_size, const char* fmt, va_list args)
518 {
519  va_list arg_copy;
520  va_copy(arg_copy, args);
521  size_t total = vsnprintf(buffer.get(), buffer_size, fmt, args);
522  if (total >= buffer_size)
523  {
524  buffer_size = total + 1;
525  buffer.reset(new char[buffer_size]);
526  vsnprintf(buffer.get(), buffer_size, fmt, arg_copy);
527  }
528  va_end(arg_copy);
529 }
530 
531 void formatToBuffer(boost::shared_array<char>& buffer, size_t& buffer_size, const char* fmt, ...)
532 {
533  va_list args;
534  va_start(args, fmt);
535 
536  vformatToBuffer(buffer, buffer_size, fmt, args);
537 
538  va_end(args);
539 }
540 
541 std::string formatToString(const char* fmt, ...)
542 {
544  size_t size = 0;
545 
546  va_list args;
547  va_start(args, fmt);
548 
549  vformatToBuffer(buffer, size, fmt, args);
550 
551  va_end(args);
552 
553  return std::string(buffer.get(), size);
554 }
555 
556 #define INITIAL_BUFFER_SIZE 4096
557 static boost::mutex g_print_mutex;
560 static boost::thread::id g_printing_thread_id;
561 void print(FilterBase* filter, void* logger_handle, Level level,
562  const char* file, int line, const char* function, const char* fmt, ...)
563 {
564  if (g_shutting_down)
565  return;
566 
567  if (g_printing_thread_id == boost::this_thread::get_id())
568  {
569  fprintf(stderr, "Warning: recursive print statement has occurred. Throwing out recursive print.\n");
570  return;
571  }
572 
573  boost::mutex::scoped_lock lock(g_print_mutex);
574 
575  g_printing_thread_id = boost::this_thread::get_id();
576 
577  va_list args;
578  va_start(args, fmt);
579 
581 
582  va_end(args);
583 
584  bool enabled = true;
585 
586  if (filter)
587  {
588  FilterParams params;
589  params.file = file;
590  params.function = function;
591  params.line = line;
592  params.level = level;
593  params.logger = logger_handle;
594  params.message = g_print_buffer.get();
595  enabled = filter->isEnabled(params);
596  level = params.level;
597 
598  if (!params.out_message.empty())
599  {
600  size_t msg_size = params.out_message.size();
601  if (g_print_buffer_size <= msg_size)
602  {
603  g_print_buffer_size = msg_size + 1;
604  g_print_buffer.reset(new char[g_print_buffer_size]);
605  }
606 
607  memcpy(g_print_buffer.get(), params.out_message.c_str(), msg_size + 1);
608  }
609  }
610 
611  if (enabled)
612  {
613  if (level == levels::Error)
614  {
616  }
617  try
618  {
619  ::ros::console::impl::print(logger_handle, level, g_print_buffer.get(), file, function, line);
620  }
621  catch (std::exception& e)
622  {
623  fprintf(stderr, "Caught exception while logging: [%s]\n", e.what());
624  }
625  }
626 
627  g_printing_thread_id = boost::thread::id();
628 }
629 
630 void print(FilterBase* filter, void* logger_handle, Level level,
631  const std::stringstream& ss, const char* file, int line, const char* function)
632 {
633  if (g_shutting_down)
634  return;
635 
636  if (g_printing_thread_id == boost::this_thread::get_id())
637  {
638  fprintf(stderr, "Warning: recursive print statement has occurred. Throwing out recursive print.\n");
639  return;
640  }
641 
642  boost::mutex::scoped_lock lock(g_print_mutex);
643 
644  g_printing_thread_id = boost::this_thread::get_id();
645 
646  bool enabled = true;
647  std::string str = ss.str();
648 
649  if (filter)
650  {
651  FilterParams params;
652  params.file = file;
653  params.function = function;
654  params.line = line;
655  params.level = level;
656  params.logger = logger_handle;
657  params.message = str.c_str();
658  enabled = filter->isEnabled(params);
659  level = params.level;
660 
661  if (!params.out_message.empty())
662  {
663  str = params.out_message;
664  }
665  }
666 
667  if (enabled)
668  {
669  if (level == levels::Error)
670  {
671  g_last_error_message = str;
672  }
673  try
674  {
675  ::ros::console::impl::print(logger_handle, level, str.c_str(), file, function, line);
676  }
677  catch (std::exception& e)
678  {
679  fprintf(stderr, "Caught exception while logging: [%s]\n", e.what());
680  }
681  }
682 
683  g_printing_thread_id = boost::thread::id();
684 }
685 
686 typedef std::vector<LogLocation*> V_LogLocation;
688 boost::mutex g_locations_mutex;
690 {
691  boost::mutex::scoped_lock lock(g_locations_mutex);
692 
693  g_log_locations.push_back(loc);
694 }
695 
697 {
699 }
700 
701 void initializeLogLocation(LogLocation* loc, const std::string& name, Level level)
702 {
703  boost::mutex::scoped_lock lock(g_locations_mutex);
704 
705  if (loc->initialized_)
706  {
707  return;
708  }
709 
711  loc->level_ = level;
712 
713  g_log_locations.push_back(loc);
714 
716 
717  loc->initialized_ = true;
718 }
719 
721 {
722  boost::mutex::scoped_lock lock(g_locations_mutex);
723  loc->level_ = level;
724 }
725 
727 {
728  boost::mutex::scoped_lock lock(g_locations_mutex);
730 }
731 
733 {
734  boost::mutex::scoped_lock lock(g_locations_mutex);
735 
736  V_LogLocation::iterator it = g_log_locations.begin();
737  V_LogLocation::iterator end = g_log_locations.end();
738  for ( ; it != end; ++it )
739  {
740  LogLocation* loc = *it;
742  }
743 }
744 
746 {
747 public:
749  {
751  }
752 };
754 
755 
757 {
759 }
760 
762 {
764 }
765 
766 void shutdown()
767 {
768  g_shutting_down = true;
770 }
771 
772 bool get_loggers(std::map<std::string, levels::Level>& loggers)
773 {
774  return ros::console::impl::get_loggers(loggers);
775 }
776 
777 bool set_logger_level(const std::string& name, levels::Level level)
778 {
779  return ros::console::impl::set_logger_level(name, level);
780 }
781 
782 } // namespace console
783 } // namespace ros
ros::console::TimeToken
Definition: rosconsole.cpp:184
ros::console::LogLocation::level_
::ros::console::Level level_
Definition: console.h:268
ros::console::M_string
std::map< std::string, std::string > M_string
Definition: rosconsole.cpp:93
ros::console::impl::get_loggers
ROSCONSOLE_CONSOLE_IMPL_DECL bool get_loggers(std::map< std::string, levels::Level > &loggers)
Definition: rosconsole_glog.cpp:110
ros::console::FilterParams::file
const char * file
[input] File the message came from
Definition: console.h:197
ros::console::deregister_appender
ROSCONSOLE_DECL void deregister_appender(LogAppender *appender)
Definition: rosconsole.cpp:761
ros::console::vformatToBuffer
ROSCONSOLE_DECL void vformatToBuffer(boost::shared_array< char > &buffer, size_t &buffer_size, const char *fmt, va_list args)
Definition: rosconsole.cpp:517
ros::console::Formatter::format_
std::string format_
Definition: console.h:136
ros::console::Formatter
Definition: console.h:129
ros::console::FilterParams::function
const char * function
[input] Function the message came from
Definition: console.h:199
print
void print(ros::console::Level level, const std::string &s)
Definition: example.cpp:38
ros::console::levels::Error
@ Error
Definition: console_backend.h:58
ros::console::FilterParams::level
Level level
[input/output] Severity level. If changed, uses the new level
Definition: console.h:204
ros::console::g_force_stdout_line_buffered
bool g_force_stdout_line_buffered
Definition: rosconsole.cpp:89
ros::console::StaticInit
Definition: rosconsole.cpp:745
ros::Time::isSimTime
static bool isSimTime()
ros::console::FilterParams::line
int line
[input] Line the message came from
Definition: console.h:198
boost::shared_ptr
ros::console::checkLogLocationEnabledNoLock
void checkLogLocationEnabledNoLock(LogLocation *loc)
Definition: rosconsole.cpp:696
ros
ros::console::FunctionToken
Definition: rosconsole.cpp:280
ros::console::g_print_buffer
static boost::shared_array< char > g_print_buffer(new char[INITIAL_BUFFER_SIZE])
time.h
ros::console::impl::getName
ROSCONSOLE_CONSOLE_IMPL_DECL std::string getName(void *handle)
Definition: rosconsole_glog.cpp:84
ros::console::FunctionToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *function, int)
Definition: rosconsole.cpp:282
ros::console::g_init_mutex
boost::mutex g_init_mutex
Definition: rosconsole.cpp:62
ros::console::LoggerToken
Definition: rosconsole.cpp:259
assert.h
ros::console::LogAppender
Definition: console.h:100
ros::console::Formatter::print
void print(void *logger_handle, ::ros::console::Level level, const char *str, const char *file, const char *function, int line)
Definition: rosconsole.cpp:395
ros::console::TimeToken::TimeToken
TimeToken(const std::string &format)
Definition: rosconsole.cpp:186
console.h
ros::console::impl::getHandle
ROSCONSOLE_CONSOLE_IMPL_DECL void * getHandle(const std::string &name)
Definition: rosconsole_glog.cpp:69
ros::console::initializeLogLocation
ROSCONSOLE_DECL void initializeLogLocation(LogLocation *loc, const std::string &name, Level level)
Internal.
Definition: rosconsole.cpp:701
ros::console::set_logger_level
ROSCONSOLE_DECL bool set_logger_level(const std::string &name, levels::Level level)
Definition: rosconsole.cpp:777
ros::console::FixedToken::str_
std::string str_
Definition: rosconsole.cpp:112
ros::console::backend::function_notifyLoggerLevelsChanged
ROSCONSOLE_BACKEND_DECL void(* function_notifyLoggerLevelsChanged)()
Definition: rosconsole_backend.cpp:47
ros::console::WallTimeToken::format_
const std::string format_
Definition: rosconsole.cpp:246
ros::console::MessageToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *str, const char *, const char *, int)
Definition: rosconsole.cpp:178
ros::console::g_print_buffer_size
static size_t g_print_buffer_size
Definition: rosconsole.cpp:559
ros::console::FilterBase
Base-class for filters. Filters allow full user-defined control over whether or not a message should ...
Definition: console.h:231
ros::console::g_last_error_message
ROSCONSOLE_DECL std::string g_last_error_message
Only exported because the TopicManager need it. Do not use directly.
Definition: rosconsole.cpp:74
ros::console::LineToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *, int line)
Definition: rosconsole.cpp:290
generate_macros.f
f
Definition: generate_macros.py:96
ROSCONSOLE_AUTOINIT
#define ROSCONSOLE_AUTOINIT
Initializes the rosconsole library. Usually unnecessary to call directly.
Definition: console.h:327
ros::console::SeverityToken
Definition: rosconsole.cpp:143
ros::console::LogLocation::logger_enabled_
bool logger_enabled_
Definition: console.h:267
ros::console::StaticInit::StaticInit
StaticInit()
Definition: rosconsole.cpp:748
ros::console::setLogLocationLevel
ROSCONSOLE_DECL void setLogLocationLevel(LogLocation *loc, Level level)
Internal.
Definition: rosconsole.cpp:720
ros::console::register_appender
ROSCONSOLE_DECL void register_appender(LogAppender *appender)
Definition: rosconsole.cpp:756
ros::console::Formatter::init
void init(const char *fmt)
Definition: rosconsole.cpp:356
ros::console::LineToken
Definition: rosconsole.cpp:288
ros::Time::isValid
static bool isValid()
ros::console::levels::Debug
@ Debug
Definition: console_backend.h:55
ros::console::FilterParams::logger
void * logger
[input/output] Handle identifying logger that this message will be output to. If changed,...
Definition: console.h:203
ros::console::levels::Count
@ Count
Definition: console_backend.h:61
ros::console::g_stdout_flush_failure_reported
bool g_stdout_flush_failure_reported
Definition: rosconsole.cpp:90
ros::console::shutdown
ROSCONSOLE_DECL void shutdown()
Definition: rosconsole.cpp:766
ros::console::ThreadToken
Definition: rosconsole.cpp:249
ros::console::g_formatter
ROSCONSOLE_DECL Formatter g_formatter
Only exported because the implementation need it. Do not use directly.
Definition: rosconsole.cpp:462
ros::console::SeverityToken::getString
virtual std::string getString(void *, ::ros::console::Level level, const char *str, const char *file, const char *function, int line)
Definition: rosconsole.cpp:145
ros::console::g_locations_mutex
boost::mutex g_locations_mutex
Definition: rosconsole.cpp:688
ros::WallTime::now
static WallTime now()
ros::console::formatToBuffer
ROSCONSOLE_DECL void formatToBuffer(boost::shared_array< char > &buffer, size_t &buffer_size, const char *fmt,...)
Definition: rosconsole.cpp:531
ros::console::g_print_mutex
static boost::mutex g_print_mutex
Definition: rosconsole.cpp:557
ros::console::registerLogLocation
ROSCONSOLE_DECL void registerLogLocation(LogLocation *loc)
Registers a logging location with the system.
Definition: rosconsole.cpp:689
boost::shared_array
Definition: console.h:73
ros::console::FixedMapToken
Definition: rosconsole.cpp:115
ros::console::WallTimeToken::WallTimeToken
WallTimeToken(const std::string &format)
Definition: rosconsole.cpp:225
TimeBase< WallTime, WallDuration >::toBoost
boost::posix_time::ptime toBoost() const
ros::console::g_extra_fixed_tokens
M_string g_extra_fixed_tokens
Definition: rosconsole.cpp:94
ros::console::FixedMapToken::str_
std::string str_
Definition: rosconsole.cpp:132
ros::console::Formatter::getTokenStrings
std::string getTokenStrings(void *logger_handle, ::ros::console::Level level, const char *str, const char *file, const char *function, int line) const
Definition: rosconsole.cpp:449
ros::console::setFixedFilterToken
ROSCONSOLE_DECL void setFixedFilterToken(const std::string &key, const std::string &val)
Definition: rosconsole.cpp:96
ros::console::levels::Level
Level
Definition: console_backend.h:53
ros::console::levels::Info
@ Info
Definition: console_backend.h:56
console_impl.h
ros::console::LogLocation::initialized_
bool initialized_
Definition: console.h:266
ros::console::PlaceHolderToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *, int)
Definition: rosconsole.cpp:137
ros::console::WallTimeToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *, int)
Definition: rosconsole.cpp:227
ros::console::createTokenFromType
TokenPtr createTokenFromType(const std::string &type)
Definition: rosconsole.cpp:298
ros::console::FixedToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *, int)
Definition: rosconsole.cpp:107
ros::console::impl::shutdown
ROSCONSOLE_CONSOLE_IMPL_DECL void shutdown()
Definition: rosconsole_glog.cpp:107
ros::console::g_format_string
const char * g_format_string
Definition: rosconsole.cpp:87
ros::console::LoggerToken::getString
virtual std::string getString(void *logger_handle, ::ros::console::Level level, const char *str, const char *file, const char *function, int line)
Definition: rosconsole.cpp:261
ros::console::FilterParams::out_message
std::string out_message
[output] If set, writes this message instead of the original
Definition: console.h:207
COLOR_NORMAL
#define COLOR_NORMAL
Definition: rosconsole.cpp:82
ros::console::checkLogLocationEnabled
ROSCONSOLE_DECL void checkLogLocationEnabled(LogLocation *loc)
Internal.
Definition: rosconsole.cpp:726
ros::console::g_log_locations
V_LogLocation g_log_locations
Definition: rosconsole.cpp:687
ros::console::LogLocation::logger_
void * logger_
Definition: console.h:269
ros::console::WallTimeToken
Definition: rosconsole.cpp:223
ros::console::g_shutting_down
bool g_shutting_down
Definition: rosconsole.cpp:61
COLOR_GREEN
#define COLOR_GREEN
Definition: rosconsole.cpp:84
ros::console::g_static_init
StaticInit g_static_init
Definition: rosconsole.cpp:753
ros::console::levels::Fatal
@ Fatal
Definition: console_backend.h:59
ros::console::notifyLoggerLevelsChanged
ROSCONSOLE_DECL void notifyLoggerLevelsChanged()
Tells the system that a logger's level has changed.
Definition: rosconsole.cpp:732
ros::get_environment_variable
bool get_environment_variable(std::string &str, const char *environment_variable)
ros::console::impl::isEnabledFor
ROSCONSOLE_CONSOLE_IMPL_DECL bool isEnabledFor(void *handle, ::ros::console::Level level)
Definition: rosconsole_glog.cpp:59
ros::console::impl::g_level_lookup
log4cxx::LevelPtr g_level_lookup[levels::Count]
Definition: rosconsole_log4cxx.cpp:69
ros::console::FileToken
Definition: rosconsole.cpp:272
ros::console::FilterParams::message
const char * message
[input] The formatted message that will be output
Definition: console.h:200
ros::console::initialize
ROSCONSOLE_DECL void initialize()
Don't call this directly. Performs any required initialization/configuration. Happens automatically w...
Definition: rosconsole.cpp:470
ros::console::FixedMapToken::FixedMapToken
FixedMapToken(const std::string &str)
Definition: rosconsole.cpp:117
ros::console::impl::deregister_appender
ROSCONSOLE_CONSOLE_IMPL_DECL void deregister_appender(LogAppender *appender)
Definition: rosconsole_glog.cpp:99
ros::console::TimeToken::format_
const std::string format_
Definition: rosconsole.cpp:220
ros::console::g_color
bool g_color
Definition: rosconsole.cpp:91
ros::console::PlaceHolderToken
Definition: rosconsole.cpp:135
ros::console::levels::Warn
@ Warn
Definition: console_backend.h:57
ros::console::ThreadToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *, int)
Definition: rosconsole.cpp:251
ros::console::TimeToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *, int)
Definition: rosconsole.cpp:188
ros::console::formatToString
ROSCONSOLE_DECL std::string formatToString(const char *fmt,...)
Definition: rosconsole.cpp:541
ros::console::_print
void _print(void *logger_handle, ::ros::console::Level level, const char *str, const char *file, const char *function, int line)
Definition: rosconsole.cpp:465
INITIAL_BUFFER_SIZE
#define INITIAL_BUFFER_SIZE
Definition: rosconsole.cpp:556
ros::console::Formatter::tokens_
V_Token tokens_
Definition: console.h:137
ros::console::MessageToken
Definition: rosconsole.cpp:176
ros::console::FixedToken::FixedToken
FixedToken(const std::string &str)
Definition: rosconsole.cpp:103
ros::console::V_LogLocation
std::vector< LogLocation * > V_LogLocation
Definition: rosconsole.cpp:686
ros::console::FilterParams
Parameter structure passed to FilterBase::isEnabled(...);. Includes both input and output parameters.
Definition: console.h:194
ros::console::print
ROSCONSOLE_DECL void print(FilterBase *filter, void *logger, Level level, const char *file, int line, const char *function, const char *fmt,...) ROSCONSOLE_PRINTF_ATTRIBUTE(7
Don't call this directly. Use the ROS_LOG() macro instead.
Definition: rosconsole.cpp:561
COLOR_YELLOW
#define COLOR_YELLOW
Definition: rosconsole.cpp:85
ros::console::FileToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *file, const char *, int)
Definition: rosconsole.cpp:274
ros::console::get_loggers
ROSCONSOLE_DECL bool get_loggers(std::map< std::string, levels::Level > &loggers)
Definition: rosconsole.cpp:772
ros::console::impl::set_logger_level
ROSCONSOLE_CONSOLE_IMPL_DECL bool set_logger_level(const std::string &name, levels::Level level)
Definition: rosconsole_glog.cpp:119
ros::console::FixedToken
Definition: rosconsole.cpp:101
ros::console::g_initialized
ROSCONSOLE_DECL bool g_initialized
Only exported because the macros need it. Do not use directly.
Definition: rosconsole.cpp:60
ros::console::Token
Definition: console.h:114
ros::console::impl::register_appender
ROSCONSOLE_CONSOLE_IMPL_DECL void register_appender(LogAppender *appender)
Definition: rosconsole_glog.cpp:94
ros::console::TokenPtr
boost::shared_ptr< Token > TokenPtr
Definition: console.h:126
ros::console::FixedMapToken::getString
virtual std::string getString(void *, ::ros::console::Level, const char *, const char *, const char *, int)
Definition: rosconsole.cpp:121
COLOR_RED
#define COLOR_RED
Definition: rosconsole.cpp:83
ros::console::backend::function_print
ROSCONSOLE_BACKEND_DECL void(* function_print)(void *, ::ros::console::Level, const char *, const char *, const char *, int)
Definition: rosconsole_backend.cpp:57
ros::Time::now
static Time now()
ros::console::FilterBase::isEnabled
virtual bool isEnabled()
Returns whether or not the log statement should be printed. Called before the log arguments are evalu...
Definition: console.h:239
ros::console::LogLocation
Internal.
Definition: console.h:264
ros::console::g_printing_thread_id
static boost::thread::id g_printing_thread_id
Definition: rosconsole.cpp:560


rosconsole
Author(s): Josh Faust
autogenerated on Wed Mar 2 2022 00:53:52