#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::_instance = NULL; nmDataLogFile* nmDataLogFile::getInstance() { if (NULL == _instance) { _instance = new nmDataLogFile(); } return _instance; } void nmDataLogFile::writeLog(const QString &message) { m_textStream << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << " - " << message << endl; m_logFile.flush(); }