#include "nmDataLogFile.h" #include #include nmDataLogFile::nmDataLogFile(QObject *parent) : QObject(parent) { m_logFile.setFileName("nmDebug.log"); if (m_logFile.open(QIODevice::WriteOnly | QIODevice::Append)) { m_textStream.setDevice(&m_logFile); m_textStream.setCodec("UTF-8"); } } nmDataLogFile::~nmDataLogFile() { m_logFile.close(); } nmDataLogFile* nmDataLogFile::s_instance = NULL; nmDataLogFile* nmDataLogFile::getInstance() { if (NULL == s_instance) { s_instance = new nmDataLogFile(); } return s_instance; } void nmDataLogFile::writeLog(const QString &message) { m_textStream << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << " - " << message << endl; m_logFile.flush(); }