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


rosconsole
Author(s): Josh Faust
autogenerated on Mon Oct 19 2020 03:52:13