diff options
-rw-r--r-- | src/tools/qglobal.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/tools/qglobal.cpp b/src/tools/qglobal.cpp index 5eeb854..3f644e2 100644 --- a/src/tools/qglobal.cpp +++ b/src/tools/qglobal.cpp @@ -492,6 +492,33 @@ void qDebug( const char *msg, ... ) } } +void debug( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + strcpy( buf, QDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() ); + int len = strlen(buf); + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( &buf[len], msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( QtDebugMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + QString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + void qWarning( const char *msg, ... ) { char buf[QT_BUFFER_LENGTH]; @@ -519,6 +546,33 @@ void qWarning( const char *msg, ... ) } } +void warning( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + strcpy( buf, QDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() ); + int len = strlen(buf); + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( &buf[len], msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( QtWarningMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + QString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + void qFatal( const char *msg, ... ) { char buf[QT_BUFFER_LENGTH]; @@ -554,6 +608,41 @@ void qFatal( const char *msg, ... ) } } +void fatal( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + strcpy( buf, QDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() ); + int len = strlen(buf); + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( &buf[len], msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( QtFatalMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif +#if defined(Q_OS_UNIX) && defined(QT_DEBUG) + abort(); // trap; generates core dump +#elif defined(Q_OS_TEMP) && defined(QT_DEBUG) + QString fstr; + fstr.sprintf( "%s:%s %s %s\n", __FILE__, __LINE__, QT_VERSION_STR, buf ); + OutputDebugString( fstr.ucs2() ); +#elif defined(_CRT_ERROR) && defined(_DEBUG) + _CrtDbgReport( _CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, buf ); +#else + exit( 1 ); // goodbye cruel world +#endif + } +} + /*! \relates QApplication |