-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlogfile.cpp
More file actions
35 lines (28 loc) · 742 Bytes
/
logfile.cpp
File metadata and controls
35 lines (28 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "logfile.h"
#include <QString>
#include <QFile>
#include <QCoreApplication>
#include <QDebug>
#include <QDateTime>
LogFile::LogFile()
{
out=NULL;
log = new QFile("/var/tmp/cmzone.log");
if (log->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
out = new QTextStream(log);
} else {
//qDebug() << "Error opening log file '" << fileName << "'. All debug output redirected to console.";
}
}
LogFile::~LogFile()
{
log->close();
}
void LogFile::add(QString msg)
{
QString debugdate = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
if(out)
(*out) << debugdate << " " << msg << endl;
else
qDebug() << debugdate << " " << msg << endl;
}