-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.cpp
More file actions
34 lines (25 loc) · 747 Bytes
/
Copy pathlogger.cpp
File metadata and controls
34 lines (25 loc) · 747 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
#include "logger.h"
#include <QThread>
#include <QDebug>
// Constructor
Logger::Logger(QObject *parent) : QObject(parent), _thread(new QThread)
{
connect(_thread, &QThread::finished, this, &QObject::deleteLater);
this->moveToThread(_thread);
_thread->start();
}
// Destructor
Logger::~Logger()
{
qDebug() << "Execute Logger::~Logger()";
_thread->quit();
_thread->requestInterruption();
_thread = nullptr;
}
// Public Slots
void Logger::writeLog(const QString &bucket, const QString &action, const QString &status, const QString &msg)
{
// qDebug() << "Logger Thread:" << this->thread();
QString message = QString("%1 [%2] %3: %4").arg(bucket).arg(action).arg(status).arg(msg);
qInfo() << message;
}