forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgddebug.cc
55 lines (43 loc) · 1.12 KB
/
gddebug.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* 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 logFile;
static QTextCodec * utf8Codec;
void gdWarning(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
QTextCodec *localeCodec = 0;
if( logFile.isOpen() )
{
if( utf8Codec == 0 )
utf8Codec = QTextCodec::codecForName( "UTF8" );
localeCodec = QTextCodec::codecForLocale();
QTextCodec::setCodecForLocale( utf8Codec );
}
qWarning( "%s", QString().vsprintf( msg, ap ).toUtf8().data() );
if( logFile.isOpen() )
{
QTextCodec::setCodecForLocale( localeCodec );
}
}
void gdDebug(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
QTextCodec *localeCodec = 0;
if( logFile.isOpen() )
{
if( utf8Codec == 0 )
utf8Codec = QTextCodec::codecForName( "UTF8" );
localeCodec = QTextCodec::codecForLocale();
QTextCodec::setCodecForLocale( utf8Codec );
}
qDebug( "%s", QString().vsprintf( msg, ap ).toUtf8().data() );
if( logFile.isOpen() )
{
QTextCodec::setCodecForLocale( localeCodec );
}
}