Main MRPT website > C++ reference for MRPT 1.5.6
CDebugOutputCapable.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #define MRPT_DISABLE_WARN_DEPRECATED_DEBUG_OUTPUT_CAPABLE
14 #include <mrpt/system/memory.h>
15 #include <mrpt/system/os.h>
16 
17 #include <vector>
18 #include <cstdarg>
19 
20 using namespace mrpt::utils;
21 using namespace mrpt::system;
22 
23 /*---------------------------------------------------------------
24  printf_debug
25  ---------------------------------------------------------------*/
26 void CDebugOutputCapable::printf_debug( const char *fmt, ... ) const
27 {
28  if (!fmt) return;
29 
30  int result = -1, length = 1024;
31  std::vector<char> buffer;
32  while (result == -1)
33  {
34  buffer.resize(length + 10);
35 
36  va_list args; // This must be done WITHIN the loop
37  va_start(args,fmt);
38  result = os::vsnprintf(&buffer[0], length, fmt, args);
39  va_end(args);
40 
41  // Truncated?
42  if (result>=length) result=-1;
43  length*=2;
44  }
45 
46  // Output:
47  std::string s(&buffer[0]);
48  COutputLogger::logStr(LVL_INFO, s);
49 }
GLuint GLsizei GLsizei * length
Definition: glew.h:1732
GLdouble s
Definition: glew.h:1295
#define vsnprintf
Definition: zutil.h:204
GLuint buffer
Definition: glew.h:1585
GLsizei const GLcharARB ** string
Definition: glew.h:3293
void printf_debug(const char *frmt,...) const MRPT_printf_format_check(2
Sends a formated text to "debugOut" if not NULL, or to cout otherwise.



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018