--- /dev/null
+/*
+@version: 0.6
+@author: Sudheer K. <scifi1947 at gmail.com>
+@license: GNU General Public License
+*/
+
+#ifndef LOGUTILITY_H
+#define LOGUTILITY_H
+#include <QFile>
+#include <QIODevice>
+#include <QTextStream>
+#include <QDateTime>
+#include <QDebug>
+
+class LogUtility : public QObject
+{
+ Q_OBJECT
+
+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;
+};
+
+#endif // LOGUTILITY_H