-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.cpp
56 lines (44 loc) · 1.29 KB
/
Logger.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "Logger.hpp"
Logger::Logger(QObject *parent)
: QObject{parent}
{
QObject::connect(&_digitalDateTimeTimer, &QTimer::timeout, this, &Logger::digitalDateTimeDisplay);
_digitalDateTimeTimer.setInterval(1000);
_digitalDateTimeTimer.start();
}
QString Logger::messageBuffer() const
{
return _messageBuffer; // Should modify this such that it newlines in the log window in QML
}
void Logger::setMessageBuffer(const QString &newMessageBuffer)
{
_messageBuffer = newMessageBuffer;
emit messageBufferChanged();
}
void Logger::outputLogMessage(const QString& message)
{
QString constructedMessage = QTime::currentTime().toString().leftJustified(9, ' ') + "| " + message;
emit logMessageOutput(constructedMessage);
// in QML, when the signal is emitted, do textAppend
}
void Logger::digitalDateTimeDisplay()
{
setDigitalDateTime(QDateTime::currentDateTime());
}
void Logger::loadUpMessageBuffer(const QString& message)
{
_messageBuffer = _messageBuffer + message + '\n';
}
void Logger::clearMessageBuffer()
{
_messageBuffer = "";
}
QDateTime Logger::digitalDateTime() const
{
return _digitalDateTime;
}
void Logger::setDigitalDateTime(const QDateTime &newDigitalDateTime)
{
_digitalDateTime = newDigitalDateTime;
emit digitalDateTimeChanged();
}