/*
+<<<<<<< HEAD
@version: 0.4
+=======
+@version: 0.6
+>>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e
@author: Sudheer K. <scifi1947 at gmail.com>
@license: GNU General Public License
*/
#ifndef LOGUTILITY_H
#define LOGUTILITY_H
+<<<<<<< HEAD
#include <QDebug>
#include <QFile>
#include <QIODevice>
#include <QDateTime>
#include <QDir>
+=======
+#include <QFile>
+#include <QIODevice>
+#include <QTextStream>
+#include <QDateTime>
+#include <QDebug>
+>>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e
class LogUtility : public QObject
{
Q_OBJECT
+<<<<<<< HEAD
private:
QFile * logFile;
qDebug() << "ERROROPENINGLOGFILE" << QString("Vicar: [%1] - %2").arg(strTimeNow,strMessage);
}
}
+=======
+public:
+ LogUtility(QString logPath,QObject *parent = 0) :
+ QObject(parent){
+ logFilePath = logPath;
+ }
+
+ ~LogUtility(){
+ }
+
+public slots:
+ void logMessage(QString strMessage, bool appendMode = true) {
+
+ QFile logFile(logFilePath);
+
+ bool success = false;
+
+ if (appendMode){
+ success = logFile.open(QIODevice::Append | QIODevice::WriteOnly | QIODevice::Text);
+ }
+ else{
+ success = logFile.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text);
+ }
+
+ QString strTimeNow = QDateTime::currentDateTime().toString("dd-MMM-yyyy HH:mm:ss");
+ if (success) {
+ QTextStream logStream(&logFile);
+ logStream << strTimeNow << " - " << strMessage << endl;
+ }
+ else{
+ qDebug() << "ERROROPENINGLOGFILE" << " - " << strMessage;
+ }
+ }
+
+private:
+ QString logFilePath;
+>>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e
};
#endif // LOGUTILITY_H