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


rosconsole
Author(s): Josh Faust
autogenerated on Mon Nov 2 2020 03:52:16