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 <QString>
|
|
|
|
#include "gddebug.hh"
|
2022-04-03 01:45:09 +00:00
|
|
|
#include <QDebug>
|
2022-02-28 16:26:59 +00:00
|
|
|
#if(QT_VERSION >= QT_VERSION_CHECK(6,0,0))
|
|
|
|
#include <QtCore5Compat/QTextCodec>
|
|
|
|
#else
|
|
|
|
#include <QTextCodec>
|
|
|
|
#endif
|
2013-11-16 18:34:09 +00:00
|
|
|
|
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-04-03 01:45:09 +00:00
|
|
|
qWarning() << QString().vasprintf( msg, ap );
|
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);
|
2022-05-15 04:41:24 +00:00
|
|
|
// QTextCodec *localeCodec = 0;
|
2013-11-16 18:34:09 +00:00
|
|
|
|
2022-05-15 04:41:24 +00:00
|
|
|
// if( logFilePtr && logFilePtr->isOpen() )
|
|
|
|
// {
|
|
|
|
// if( utf8Codec == 0 )
|
|
|
|
// utf8Codec = QTextCodec::codecForName( "UTF8" );
|
2013-11-16 18:34:09 +00:00
|
|
|
|
2022-05-15 04:41:24 +00:00
|
|
|
// localeCodec = QTextCodec::codecForLocale();
|
|
|
|
// QTextCodec::setCodecForLocale( utf8Codec );
|
|
|
|
// }
|
2013-11-16 18:34:09 +00:00
|
|
|
|
2022-05-16 14:10:12 +00:00
|
|
|
qDebug().noquote() << QString().vasprintf( msg, ap );
|
2013-11-16 18:34:09 +00:00
|
|
|
|
2022-05-15 04:41:24 +00:00
|
|
|
// if( logFilePtr && logFilePtr->isOpen() )
|
|
|
|
// {
|
|
|
|
// QTextCodec::setCodecForLocale( localeCodec );
|
|
|
|
// }
|
2017-09-16 13:34:45 +00:00
|
|
|
|
|
|
|
va_end(ap);
|
2013-11-16 18:34:09 +00:00
|
|
|
}
|