You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
781 B
C++
34 lines
781 B
C++
#include "nmDataLogFile.h"
|
|
#include <QFile>
|
|
#include <QDateTime>
|
|
|
|
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();
|
|
}
|