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


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