opt: debug log message

convert GDPRINTF macro to gdDebug internal
This commit is contained in:
Xiao YiFang 2022-05-15 12:41:24 +08:00
parent 609cfa74b5
commit dab5885b02
4 changed files with 17 additions and 17 deletions

View file

@ -42,23 +42,23 @@ void gdDebug(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
QTextCodec *localeCodec = 0;
// QTextCodec *localeCodec = 0;
if( logFilePtr && logFilePtr->isOpen() )
{
if( utf8Codec == 0 )
utf8Codec = QTextCodec::codecForName( "UTF8" );
// if( logFilePtr && logFilePtr->isOpen() )
// {
// if( utf8Codec == 0 )
// utf8Codec = QTextCodec::codecForName( "UTF8" );
localeCodec = QTextCodec::codecForLocale();
QTextCodec::setCodecForLocale( utf8Codec );
}
// localeCodec = QTextCodec::codecForLocale();
// QTextCodec::setCodecForLocale( utf8Codec );
// }
qDebug()<< QString().vasprintf( msg, ap );
if( logFilePtr && logFilePtr->isOpen() )
{
QTextCodec::setCodecForLocale( localeCodec );
}
// if( logFilePtr && logFilePtr->isOpen() )
// {
// QTextCodec::setCodecForLocale( localeCodec );
// }
va_end(ap);
}

View file

@ -7,7 +7,7 @@
#define GD_DPRINTF(...) do {} while( 0 )
#define GD_FDPRINTF(...) do {} while( 0 )
#else
#define GD_DPRINTF(...) printf(__VA_ARGS__)
#define GD_DPRINTF(...) gdDebug(__VA_ARGS__)
#define GD_FDPRINTF(...) fprintf(__VA_ARGS__)
#endif

View file

@ -120,7 +120,7 @@ bool MdictParser::open( const char * filename )
filename_ = QString::fromUtf8( filename );
file_ = new QFile( filename_ );
GD_DPRINTF( "MdictParser: open %s\n", filename );
gdDebug( "MdictParser: open %s", filename );
if ( file_.isNull() || !file_->exists() )
return false;

6
mdx.cc
View file

@ -523,7 +523,7 @@ void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
if( firstIteration && getArticleCount() > FTS::MaxDictionarySizeForFastSearch )
return;
gdDebug( "MDict: Building the full-text index for dictionary: %s\n",
gdDebug( "MDict: Building the full-text index for dictionary: %s",
getName().c_str() );
try
@ -533,7 +533,7 @@ void MdxDictionary::makeFTSIndex( QAtomicInt & isCancelled, bool firstIteration
}
catch( std::exception &ex )
{
gdWarning( "MDict: Failed building full-text search index for \"%s\", reason: %s\n", getName().c_str(), ex.what() );
gdWarning( "MDict: Failed building full-text search index for \"%s\", reason: %s", getName().c_str(), ex.what() );
QFile::remove( FsEncoding::decode( ftsIdxName.c_str() ) );
}
}
@ -550,7 +550,7 @@ void MdxDictionary::getArticleText( uint32_t articleAddress, QString & headword,
}
catch( std::exception &ex )
{
gdWarning( "MDict: Failed retrieving article from \"%s\", reason: %s\n", getName().c_str(), ex.what() );
gdWarning( "MDict: Failed retrieving article from \"%s\", reason: %s", getName().c_str(), ex.what() );
}
}