2013-11-16 18:34:09 +00:00
|
|
|
/* This file is (c) 2013 Abs62
|
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#include <QTextCodec>
|
|
|
|
#include <QString>
|
|
|
|
#include "gddebug.hh"
|
|
|
|
|
2018-05-22 14:37:21 +00:00
|
|
|
QFile * logFilePtr;
|
2013-11-16 18:34:09 +00:00
|
|
|
static QTextCodec * utf8Codec;
|
|
|
|
|
|
|
|
void gdWarning(const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, msg);
|
|
|
|
QTextCodec *localeCodec = 0;
|
|
|
|
|
2018-05-22 14:37:21 +00:00
|
|
|
if( logFilePtr && logFilePtr->isOpen() )
|
2013-11-16 18:34:09 +00:00
|
|
|
{
|
|
|
|
if( utf8Codec == 0 )
|
|
|
|
utf8Codec = QTextCodec::codecForName( "UTF8" );
|
|
|
|
|
|
|
|
localeCodec = QTextCodec::codecForLocale();
|
|
|
|
QTextCodec::setCodecForLocale( utf8Codec );
|
|
|
|
}
|
|
|
|
|
2022-01-08 13:16:22 +00:00
|
|
|
qWarning( "%s", QString().vasprintf( msg, ap ).toUtf8().data() );
|
2013-11-16 18:34:09 +00:00
|
|
|
|
2018-05-22 14:37:21 +00:00
|
|
|
if( logFilePtr && logFilePtr->isOpen() )
|
2013-11-16 18:34:09 +00:00
|
|
|
{
|
|
|
|
QTextCodec::setCodecForLocale( localeCodec );
|
|
|
|
}
|
2017-09-16 13:34:45 +00:00
|
|
|
|
|
|
|
va_end(ap);
|
2013-11-16 18:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gdDebug(const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, msg);
|
|
|
|
QTextCodec *localeCodec = 0;
|
|
|
|
|
2018-05-22 14:37:21 +00:00
|
|
|
if( logFilePtr && logFilePtr->isOpen() )
|
2013-11-16 18:34:09 +00:00
|
|
|
{
|
|
|
|
if( utf8Codec == 0 )
|
|
|
|
utf8Codec = QTextCodec::codecForName( "UTF8" );
|
|
|
|
|
|
|
|
localeCodec = QTextCodec::codecForLocale();
|
|
|
|
QTextCodec::setCodecForLocale( utf8Codec );
|
|
|
|
}
|
|
|
|
|
2022-01-08 13:16:22 +00:00
|
|
|
qDebug( "%s", QString().vasprintf( msg, ap ).toUtf8().data() );
|
2013-11-16 18:34:09 +00:00
|
|
|
|
2018-05-22 14:37:21 +00:00
|
|
|
if( logFilePtr && logFilePtr->isOpen() )
|
2013-11-16 18:34:09 +00:00
|
|
|
{
|
|
|
|
QTextCodec::setCodecForLocale( localeCodec );
|
|
|
|
}
|
2017-09-16 13:34:45 +00:00
|
|
|
|
|
|
|
va_end(ap);
|
2013-11-16 18:34:09 +00:00
|
|
|
}
|