This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
modern-linbo-gui/sources/backend/linbologger.cpp
Dorian Zedler 06dd8c4be3
- added log text
- started to implement autostart
2020-11-24 20:25:39 +01:00

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();
}