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


rosconsole
Author(s): Josh Faust
autogenerated on Thu Apr 4 2019 02:50:43