-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflogger.cpp
More file actions
36 lines (24 loc) · 809 Bytes
/
flogger.cpp
File metadata and controls
36 lines (24 loc) · 809 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 <QFile>
#include <QTextStream>
#include "flogger.h"
#include "libfusion.h"
void FLogger::append(QString fileName, QString message)
{
QDir d(LibFusion::getWorkingDir().absolutePath() + QDir::separator() + "Logs");
if (!d.exists())
d.mkpath(".");
QString date = "[" + QDateTime::currentDateTime().toString(Qt::ISODate) + "] ";
QFile file(d.absolutePath() + QDir::separator() + fileName);
if (file.open(QIODevice::ReadOnly | QIODevice::Append))
{
QTextStream stream(&file);
stream << date << message << endl;
file.close();
}
}
void FLogger::clear(QString fileName)
{
QFile log(LibFusion::getWorkingDir().absolutePath() + QDir::separator() + "Logs" + QDir::separator() + fileName);
if (log.exists())
log.remove();
}