X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fvicar-lib%2Fcpp%2Flogutility.h;fp=src%2Fvicar-lib%2Fcpp%2Flogutility.h;h=6c89c783830591866207314fb2e916b15be27f56;hb=2beca638f4ba146e25320c9c07cc1f29d0b2bba2;hp=ebca69e5c876fc156bc3cf6ccaac94566d4c8c67;hpb=74800375ecf7f41e290cf7cc7fa9ee8b230be68e;p=vicar diff --git a/src/vicar-lib/cpp/logutility.h b/src/vicar-lib/cpp/logutility.h index ebca69e..6c89c78 100644 --- a/src/vicar-lib/cpp/logutility.h +++ b/src/vicar-lib/cpp/logutility.h @@ -1,21 +1,85 @@ /* +<<<<<<< HEAD +@version: 0.4 +======= @version: 0.6 +>>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e @author: Sudheer K. @license: GNU General Public License */ #ifndef LOGUTILITY_H #define LOGUTILITY_H +<<<<<<< HEAD +#include +#include +#include +#include +#include +======= #include #include #include #include #include +>>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e class LogUtility : public QObject { Q_OBJECT +<<<<<<< HEAD +private: + QFile * logFile; + +public: + LogUtility(QObject *parent = 0) : + QObject(parent){ + QString strPath; + +#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) + //For maemo fremantle or harmattan use a common path + QDir logDir = QDir(QDir().homePath() + "/.vicar"); + if (!logDir.exists()){ + if (QDir().mkpath(logDir.absolutePath())){ + qDebug() << "Vicar: Log directory created successfully"; + } + else{ + qDebug() << "Vicar: Error creating log directory"; + } + } + strPath = logDir.absolutePath() + "/vicar.log"; +#else + strPath = "vicar.log"; +#endif + logFile = new QFile(strPath,this); + + if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { + qDebug() << "Vicar: Error opening logfile for writing at path " << strPath; + } + } + + ~LogUtility(){ + if (logFile->isOpen()) + logFile->close(); + qDebug() << "Vicar: In LogUtility object destructor.."; + } + +public slots: + void logMessage(QString strMessage) { + + QString strTimeNow = QDateTime::currentDateTime().toString("dd-MMM-yyyy HH:mm:ss"); + + if (logFile->isOpen() && logFile->isWritable()) { + QTextStream logStream(logFile); + logStream << QString("[%1] - %2").arg(strTimeNow,strMessage) << endl; + qDebug() << QString("Vicar: [%1] - %2").arg(strTimeNow,strMessage); + } + else{ + qDebug() << "ERROROPENINGLOGFILE" << QString("Vicar: [%1] - %2").arg(strTimeNow,strMessage); + } + } +======= public: LogUtility(QString logPath,QObject *parent = 0) : QObject(parent){ @@ -51,6 +115,7 @@ public slots: private: QString logFilePath; +>>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e }; #endif // LOGUTILITY_H