34 lines
885 B
C++
34 lines
885 B
C++
#include "../../headers/backend/linbologger.h"
|
|
|
|
LinboLogger::LinboLogger(QObject *parent) : QObject(parent)
|
|
{
|
|
|
|
}
|
|
|
|
QString LinboLogger::logTypeToString(LinboLogType logType) {
|
|
switch (logType) {
|
|
case StdErr:
|
|
return "StrErr";
|
|
case StdOut:
|
|
return "StdOut";
|
|
case LinboGuiInfo:
|
|
return "Info";
|
|
case LinboGuiError:
|
|
return "Error";
|
|
default:
|
|
return "UNKNOW";
|
|
}
|
|
}
|
|
|
|
void LinboLogger::log(QString logText, LinboLogType logType) {
|
|
if(logText.isEmpty() || logText == "")
|
|
return;
|
|
qDebug() << qPrintable("[" + this->logTypeToString(logType) + "]") << logText;
|
|
LinboLog latestLog {logText, logType, QDateTime::currentDateTime()};
|
|
this->logHistory.append(latestLog);
|
|
emit this->latestLogChanged(latestLog);
|
|
}
|
|
|
|
const LinboLogger::LinboLog& LinboLogger::getLatestLog() {
|
|
return this->logHistory.last();
|
|
}
|