3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
15 class LogUtility : public QObject
23 LogUtility(QObject *parent = 0) :
27 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
28 //For maemo fremantle or harmattan use a common path
29 strPath = QDir().homePath() + "/.marketstoday/marketstoday.log";
31 strPath = "marketstoday.log";
33 logFile = new QFile(strPath,this);
35 if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
36 qDebug() << "MT: Error opening logfile for writing";
41 if (logFile->isOpen())
43 qDebug() << "Markets Today: In LogUtility object destructor..";
47 void logMessage(QString strMessage) {
49 QString strTimeNow = QDateTime::currentDateTime().toString("dd-MMM-yyyy HH:mm:ss");
50 qDebug() << QString("MT: [%1] - %2").arg(strTimeNow,strMessage);
52 if (logFile->isOpen() && logFile->isWritable()) {
53 QTextStream logStream(logFile);
54 logStream << QString("[%1] - %2").arg(strTimeNow,strMessage) << endl;
59 #endif // LOGUTILITY_H