22         #define WIN32_LEAN_AND_MEAN    47 std::string COutputLogger::logging_levels_to_names[NUMBER_OF_VERBOSITY_LEVELS] = {
    59 COutputLogger::COutputLogger() {
    62 COutputLogger::~COutputLogger() { }
    64 void COutputLogger::logStr(
const VerbosityLevel 
level, 
const std::string& msg_str)
 const {
    65         if (
level<m_min_verbosity_level)
    69         TMsg msg(
level, msg_str, *
this);
    70         if (logging_enable_keep_record)
    71                 m_history.push_back(msg);
    73         if (logging_enable_console_output) {
    78         for (
const auto &
c : m_listCallbacks)
    79                 (*
c.func)(msg.body,msg.level,msg.name,msg.timestamp,
c.userParam);
    82 void COutputLogger::logFmt(
const VerbosityLevel 
level, 
const char* fmt, ...)
 const {
    93         std::string str = this->generateStringFromFormat(fmt, argp);
    96         this->logStr(
level,str);
    99 std::string COutputLogger::generateStringFromFormat(
const char* fmt, va_list argp)
 const{
   100         int   result = -1, 
length = 1024;
   111                 if (result>=
length) result=-1;
   119 void COutputLogger::logCond(
const VerbosityLevel 
level, 
bool cond, 
const std::string& msg_str)
 const   122         this->logStr(
level,msg_str);
   127 std::string COutputLogger::getLoggerName()
 const { 
return m_logger_name; }
   129 void COutputLogger::setMinLoggingLevel(
const VerbosityLevel 
level ) {
   130         m_min_verbosity_level = 
level;
   132 void COutputLogger::setVerbosityLevel(
const VerbosityLevel 
level) {
   133         m_min_verbosity_level = 
level;
   136 void COutputLogger::getLogAsString(
std::string& fname)
 const {
   138         for (
const auto & h : m_history)
   139                 fname += h.getAsString();
   143         this->getLogAsString(str);
   146 void COutputLogger::writeLogToFile(
const std::string* fname_in )
 const {
   153                 fname = m_logger_name + 
".log";
   157                         mrpt::format(
"\n[%s:] Could not open external file: %s",
   158                                 m_logger_name.c_str(), fname.c_str()) );
   161         this->getLogAsString(hist_str);
   162         fstream.printf(
"%s", hist_str.c_str());
   166 void COutputLogger::dumpLogToConsole()
 const{
   167         for (
const auto &h :m_history)
   171 std::string COutputLogger::getLoggerLastMsg()
 const {
   172         TMsg last_msg = m_history.back();
   173         return last_msg.getAsString();
   176 void COutputLogger::getLoggerLastMsg(
std::string& msg_str)
 const {
   177         msg_str = this->getLoggerLastMsg();
   181 void COutputLogger::loggerReset() {
   182         m_logger_name = 
"log"; 
   185         logging_enable_console_output = 
true;
   186         logging_enable_keep_record    = 
false;
   190         m_min_verbosity_level = LVL_INFO;
   196 COutputLogger::TMsg::TMsg(
const mrpt::utils::VerbosityLevel 
level, 
const std::string& msg_str, 
const COutputLogger& logger) {
   199         name = logger.getLoggerName();
   204 COutputLogger::TMsg::~TMsg() { }
   213 std::string COutputLogger::TMsg::getAsString()
 const {
   216         out << 
"[" << 
name <<  
"|" << COutputLogger::logging_levels_to_names[
level]  << 
"|"   219         if (!body.empty() && *body.rbegin()!=
'\n')
   224 void COutputLogger::TMsg::getAsString(
std::string* contents)
 const {
   225         *contents = this->getAsString();
   229         out.
printf(
"%s", str.c_str());
   231         OutputDebugStringA(str.c_str());
   234 void COutputLogger::TMsg::dumpToConsole()
 const {
   237         const bool dump_to_cerr = (
level==LVL_ERROR); 
   243         (dump_to_cerr ? std::cerr : std::cout) << str;
   247         OutputDebugStringA(str.c_str());  
   251 void COutputLogger::logRegisterCallback(output_logger_callback_t  userFunc, 
void *userParam )
   256         cbe.userParam = userParam;
   257         m_listCallbacks.insert(cbe);
   260 void COutputLogger::logDeregisterCallback(output_logger_callback_t  userFunc, 
void *userParam )
   265         cbe.userParam = userParam;
   266         m_listCallbacks.erase(cbe);
 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL. 
 
int BASE_IMPEXP vsnprintf(char *buf, size_t bufSize, const char *format, va_list args) MRPT_NO_THROWS
An OS-independent version of vsnprintf (Notice the bufSize param, which may be ignored in some compil...
 
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
 
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentTime()
Returns the current (UTC) system time. 
 
void BASE_IMPEXP setConsoleColor(TConsoleColor color, bool changeStdErr=false)
Changes the text color in the console for the text written from now on. 
 
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
 
This CStream derived class allow using a file as a write-only, binary stream. 
 
TConsoleColor
For use in setConsoleColor. 
 
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf. 
 
GLsizei const GLchar ** string
 
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable. 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
GLuint GLsizei GLsizei * length
 
std::string BASE_IMPEXP timeLocalToString(const mrpt::system::TTimeStamp t, unsigned int secondFractionDigits=6)
Convert a timestamp into this textual form (in local time): HH:MM:SS.MMMMMM. 
 
GLuint const GLchar * name
 
#define ASSERTMSG_(f, __ERROR_MSG)
 
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.