Main MRPT website > C++ reference for MRPT 1.5.7
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 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:29
GLuint buffer
Definition: glext.h:3775
GLdouble s
Definition: glext.h:3602
#define vsnprintf
Definition: zutil.h:204
GLsizei const GLchar ** string
Definition: glext.h:3919
GLuint GLsizei GLsizei * length
Definition: glext.h:3900
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.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019