summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-04-27 14:53:38 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2019-04-27 14:53:38 +0900
commit835a7b87e78338bed2795a47c1abefa60935e84d (patch)
tree993700234dbd6616adc6d2da1eb79b93967073f5
parent5a61151fe90ed84dce18998fe6c7d69ec6e49c74 (diff)
downloadtqt3-835a7b87e78338bed2795a47c1abefa60935e84d.tar.gz
tqt3-835a7b87e78338bed2795a47c1abefa60935e84d.zip
Added timestamp to debug functions (tqDebug, tqWarning, tqFatal).
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--src/tools/qglobal.cpp107
1 files changed, 13 insertions, 94 deletions
diff --git a/src/tools/qglobal.cpp b/src/tools/qglobal.cpp
index 8d7edf1d3..46d90e1bb 100644
--- a/src/tools/qglobal.cpp
+++ b/src/tools/qglobal.cpp
@@ -41,6 +41,7 @@
#include "qplatformdefs.h"
#include "ntqasciidict.h"
+#include <ntqdatetime.h>
#include <limits.h>
#include <stdio.h>
#include <limits.h>
@@ -464,42 +465,17 @@ static void mac_default_handler( const char *msg )
#endif
-
void tqDebug( const char *msg, ... )
{
char buf[QT_BUFFER_LENGTH];
+ strcpy( buf, TQDateTime::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, QT_BUFFER_LENGTH, msg, ap );
-#else
- vsprintf( buf, msg, ap );
-#endif
- va_end( ap );
- if ( handler ) {
- (*handler)( TQtDebugMsg, buf );
- } else {
-#if defined(Q_CC_MWERKS)
- mac_default_handler(buf);
-#elif defined(Q_OS_TEMP)
- TQString fstr( buf );
- OutputDebugString( (fstr + "\n").ucs2() );
-#else
- fprintf( stderr, "%s\n", buf ); // add newline
-#endif
- }
-}
-
-// copied... this looks really bad.
-void debug( const char *msg, ... )
-{
- char buf[QT_BUFFER_LENGTH];
- va_list ap;
- va_start( ap, msg ); // use variable arg list
-#if defined(QT_VSNPRINTF)
- QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap );
+ QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap );
#else
- vsprintf( buf, msg, ap );
+ vsprintf( &buf[len], msg, ap );
#endif
va_end( ap );
if ( handler ) {
@@ -519,39 +495,14 @@ void debug( const char *msg, ... )
void tqWarning( const char *msg, ... )
{
char buf[QT_BUFFER_LENGTH];
+ strcpy( buf, TQDateTime::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, QT_BUFFER_LENGTH, msg, ap );
-#else
- vsprintf( buf, msg, ap );
-#endif
- va_end( ap );
- if ( handler ) {
- (*handler)( TQtWarningMsg, buf );
- } else {
-#if defined(Q_CC_MWERKS)
- mac_default_handler(buf);
-#elif defined(Q_OS_TEMP)
- TQString fstr( buf );
- OutputDebugString( (fstr + "\n").ucs2() );
-#else
- fprintf( stderr, "%s\n", buf ); // add newline
-#endif
- }
-}
-
-
-// again, copied
-void warning( const char *msg, ... )
-{
- char buf[QT_BUFFER_LENGTH];
- va_list ap;
- va_start( ap, msg ); // use variable arg list
-#if defined(QT_VSNPRINTF)
- QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap );
+ QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap );
#else
- vsprintf( buf, msg, ap );
+ vsprintf( &buf[len], msg, ap );
#endif
va_end( ap );
if ( handler ) {
@@ -571,46 +522,14 @@ void warning( const char *msg, ... )
void tqFatal( const char *msg, ... )
{
char buf[QT_BUFFER_LENGTH];
+ strcpy( buf, TQDateTime::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, QT_BUFFER_LENGTH, msg, ap );
-#else
- vsprintf( buf, msg, ap );
-#endif
- va_end( ap );
- if ( handler ) {
- (*handler)( TQtFatalMsg, 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)
- TQString fstr;
- fstr.sprintf( "%s:%s %s %s\n", __FILE__, __LINE__, TQT_VERSION_STR, buf );
- OutputDebugString( fstr.ucs2() );
-#elif defined(_CRT_ERROR) && defined(_DEBUG)
- _CrtDbgReport( _CRT_ERROR, __FILE__, __LINE__, TQT_VERSION_STR, buf );
-#else
- exit( 1 ); // goodbye cruel world
-#endif
- }
-}
-
-// yet again, copied
-void fatal( const char *msg, ... )
-{
- char buf[QT_BUFFER_LENGTH];
- va_list ap;
- va_start( ap, msg ); // use variable arg list
-#if defined(QT_VSNPRINTF)
- QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap );
+ QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap );
#else
- vsprintf( buf, msg, ap );
+ vsprintf( &buf[len], msg, ap );
#endif
va_end( ap );
if ( handler ) {