From 42df5a6feae67881f88fa4e2f26cb17323292fb0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 2 Jul 2008 22:02:44 +0000 Subject: [PATCH] 2008-07-02 23:44 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/rtl/gtwvt/gtwvt.c ! Removed unused variable. --- harbour/source/rtl/errorint.c | 47 +++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/harbour/source/rtl/errorint.c b/harbour/source/rtl/errorint.c index af2156715b..7bdf2a6115 100644 --- a/harbour/source/rtl/errorint.c +++ b/harbour/source/rtl/errorint.c @@ -53,7 +53,8 @@ #include "hbapi.h" #include "hbapierr.h" #include "hbapilng.h" -#include "hbstack.h" +#include "hbdate.h" +#include "hbset.h" /* NOTE: Use as minimal calls from here, as possible. Don't allocate memory from this function. [vszakats] */ @@ -61,6 +62,10 @@ void hb_errInternal( ULONG ulIntCode, const char * szText, const char * szPar1, const char * szPar2 ) { char buffer[ 1024 ]; + USHORT uiLine; + int iLevel; + FILE * hLog; + BOOL fLang; HB_TRACE(HB_TR_DEBUG, ("hb_errInternal(%lu, %s, %s, %s)", ulIntCode, szText, szPar1, szPar2)); @@ -73,6 +78,22 @@ void hb_errInternal( ULONG ulIntCode, const char * szText, const char * szPar1, fLang = ( hb_langID() != NULL ); + hLog = hb_fopen( hb_setGetCPtr( HB_SET_HBOUTLOG ), "a+" ); + + if( hLog ) + { + char szTime[ 9 ]; + int iYear, iMonth, iDay; + + hb_dateToday( &iYear, &iMonth, &iDay ); + hb_dateTimeStr( szTime ); + + fprintf( hLog, HB_I_("Application Internal Error - %s\n"), hb_cmdargARGV()[0] ); + fprintf( hLog, HB_I_("Terminated at: %04d.%02d.%02d %s\n"), iYear, iMonth, iDay, szTime ); + if( *hb_setGetCPtr( HB_SET_HBOUTLOGINFO ) ) + fprintf( hLog, HB_I_("Info: %s\n"), hb_setGetCPtr( HB_SET_HBOUTLOGINFO ) ); + } + hb_conOutErr( hb_conNewLine(), 0 ); if( fLang ) snprintf( buffer, sizeof( buffer ), ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRINTR ), ulIntCode ); @@ -80,16 +101,38 @@ void hb_errInternal( ULONG ulIntCode, const char * szText, const char * szPar1, snprintf( buffer, sizeof( buffer ), "Unrecoverable error %lu: ", ulIntCode ); hb_conOutErr( buffer, 0 ); + if( hLog ) + fwrite( buffer, sizeof( buffer[ 0 ] ), strlen( buffer ), hLog ); + if( szText ) snprintf( buffer, sizeof( buffer ), szText, szPar1, szPar2 ); else if( fLang ) snprintf( buffer, sizeof( buffer ), ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRINTR + ulIntCode - 9000 ), szPar1, szPar2 ); else buffer[ 0 ] = '\0'; + hb_conOutErr( buffer, 0 ); hb_conOutErr( hb_conNewLine(), 0 ); + if( hLog ) + fprintf( hLog, "%s\n", buffer ); - hb_stackDispCall(); + iLevel = 0; + while( hb_procinfo( iLevel++, buffer, &uiLine, NULL ) ) + { + char msg[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 32 ]; + + snprintf( msg, sizeof( msg ), HB_I_("Called from %s(%hu)\n"), buffer, uiLine ); + + hb_conOutErr( msg, 0 ); + if( hLog ) + fwrite( msg, sizeof( msg[ 0 ] ), strlen( msg ), hLog ); + } + + if( hLog ) + { + fprintf( hLog, "------------------------------------------------------------------------\n"); + fclose( hLog ); + } /* release console settings */ hb_conRelease();