Logo Search packages:      
Sourcecode: kmess version File versions

void kmessDebugPrinter ( QtMsgType  type,
const char *  message 
)

A Qt debug message handler.

This function can be installed using

 qInstallMsgHandler( kmessDebugPrinter ); 
It's used to avoid unwanted exit(1) or abort() calls.

Parameters:
type The debug message type, generated by qDebug(), qFatal(), etc..
message The message to print.

Definition at line 165 of file kmessdebug.cpp.

Referenced by KMessApplication::KMessApplication().

{
  bool isAssert = ( strncmp( message, "ASSERT", 7 ) == 0 ); // 'ASSERT failure' or 'ASSERT: '
  static QTime timer;
  if( ! timer.isValid() )
    timer.start();
  float elapsed = (float)timer.elapsed() / (float)1000;

  if( isAssert )
  {
    // can be qWarning() by us or qFatal() from Qt.
    fprintf( stderr, "%.3f> kmess(%d) %s\n", elapsed, getpid(), message );

#ifdef KMESSTEST
    // Crash on qFatal() from Qt, called from Q_ASSERT()
    // Don't crash on qWarning() from KMESS_ASSERT(). Could be triggered by bad P2P clients for example.
    if( type == QtFatalMsg )
    {
      abort();
    }
#endif
  }
  else
  {
    switch( type )
    {
      case QtDebugMsg:
        fprintf( stderr, "%.3f> %s\n", elapsed, message );
        break;

      case QtWarningMsg:
        fprintf( stderr, "%.3f> WARNING: %s\n", elapsed, message );
        break;

      case QtCriticalMsg:
        fprintf( stderr, "%.3f> CRITICAL: %s\n", elapsed, message );
        break;

      case QtFatalMsg:
        fprintf( stderr, "%.3f> FATAL: %s\n", elapsed, message );

#ifdef KMESSTEST
        abort();
#endif

        break;
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index