PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/safeFatPrinter/trunk/src/config.h

http://cupsfilter.googlecode.com/
C++ Header | 47 lines | 41 code | 6 blank | 0 comment | 2 complexity | be4ce7bcc8c58f187a0c20ea9dba81d7 MD5 | raw file
 1#ifndef CONFIG_H
 2#define CONFIG_H
 3#include <QFile>
 4#include <QSettings>
 5#include <QTextStream>
 6#include <QDateTime>
 7
 8
 9
10void myMessageOutput(QtMsgType type, const char *msg)
11{
12      QSettings settings(QSettings::IniFormat, QSettings::UserScope,"??????????","?????????? ???????");
13      settings.setIniCodec("UTF-8");
14      settings.beginGroup( "LOG" );
15#if defined(Q_OS_UNIX)
16	QFile logFile(settings.value("printer_log","/var/log/safeprinter/safe_printer.log").toString());
17#elif defined(Q_OS_WIN)
18	QFile logFile(settings.value("printer_log","c:\\spool\\safe_printer.log").toString());
19#endif
20      settings.endGroup();
21    if (!logFile.open(QFile::Append| QFile::Text)){
22	logFile.open(stderr, QIODevice::WriteOnly);
23    }
24
25     QTextStream out;
26     out.setDevice(&logFile);
27     out.setCodec("UTF-8");
28
29     out << "\nDateTime: " << QDateTime::currentDateTime ().toString("dd.MM.yyyy hh:mm:ss") <<"\n";
30     switch (type) {
31     case QtDebugMsg:
32	out << QObject::trUtf8("Debug: %1\n").arg(QString(msg)) <<"\n";
33	 break;
34     case QtWarningMsg:
35	 out << QObject::trUtf8("Warning: %1\n").arg(QString(msg))<<"\n";
36	 break;
37     case QtCriticalMsg:
38	 out << QObject::trUtf8("Critical: %1\n").arg(QString(msg))<<"\n";
39	 break;
40     case QtFatalMsg:
41	 out << QObject::trUtf8("Fatal: %1\n").arg(QString(msg))<<"\n";
42	 abort();
43     }
44     logFile.close();
45}
46
47#endif