Esempio n. 1
0
std::ostream & dout(DebugLevel lev,DebugClass cl)
{
 if( (lev & debugLevel) && (cl & debugClass) )
 {
  debugFile.file << std::endl;
  debugFile.currentTime() << " ";
  if( lev != debugLevel )
   debugFile.file << lev;
  if( cl != debugClass )
   debugFile.file << cl;
  debugFile.file << ": ";

  // Backtrace on error.
#if !(defined _WIN32 || defined WINDOWS)
  if( lev == D_ERROR )
  {
   int count = backtrace( tracePtrs, TRACE_SIZE );
   char** funcNames = backtrace_symbols( tracePtrs, count );
   for(int i = 0; i < count; ++i)
    debugFile.file << "\n\t(" << funcNames[i] << "), ";
   debugFile.file << "\n\t";
   free(funcNames);
  }
#endif

  return debugFile.file;
 }
 return nullStream;
}
Esempio n. 2
0
std::ostream &DebugLog( DebugLevel lev, DebugClass cl )
{
    // Error are always logged, they are important,
    // Messages from D_MAIN come from debugmsg and are equally important.
    if( ( ( lev & debugLevel ) && ( cl & debugClass ) ) || lev & D_ERROR || cl & D_MAIN ) {
        debugFile.file << std::endl;
        debugFile.currentTime() << " ";
        if( lev != debugLevel ) {
            debugFile.file << lev;
        }
        if( cl != debugClass ) {
            debugFile.file << cl;
        }
        debugFile.file << ": ";

        // Backtrace on error.
#ifdef BACKTRACE
        if( lev == D_ERROR ) {
            int count = backtrace( tracePtrs, TRACE_SIZE );
            char **funcNames = backtrace_symbols( tracePtrs, count );
            for( int i = 0; i < count; ++i ) {
                debugFile.file << "\n\t(" << funcNames[i] << "), ";
            }
            debugFile.file << "\n\t";
            free( funcNames );
        }
#endif

        return debugFile.file;
    }
    return nullStream;
}