加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gddebug.cc 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
Abs62 提交于 2018-05-22 17:37 . Little refactoring for log messages to file
/* 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"
QFile * logFilePtr;
static QTextCodec * utf8Codec;
void gdWarning(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
QTextCodec *localeCodec = 0;
if( logFilePtr && logFilePtr->isOpen() )
{
if( utf8Codec == 0 )
utf8Codec = QTextCodec::codecForName( "UTF8" );
localeCodec = QTextCodec::codecForLocale();
QTextCodec::setCodecForLocale( utf8Codec );
}
qWarning( "%s", QString().vsprintf( msg, ap ).toUtf8().data() );
if( logFilePtr && logFilePtr->isOpen() )
{
QTextCodec::setCodecForLocale( localeCodec );
}
va_end(ap);
}
void gdDebug(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
QTextCodec *localeCodec = 0;
if( logFilePtr && logFilePtr->isOpen() )
{
if( utf8Codec == 0 )
utf8Codec = QTextCodec::codecForName( "UTF8" );
localeCodec = QTextCodec::codecForLocale();
QTextCodec::setCodecForLocale( utf8Codec );
}
qDebug( "%s", QString().vsprintf( msg, ap ).toUtf8().data() );
if( logFilePtr && logFilePtr->isOpen() )
{
QTextCodec::setCodecForLocale( localeCodec );
}
va_end(ap);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化