-
Notifications
You must be signed in to change notification settings - Fork 4
/
logger.cpp
83 lines (69 loc) · 1.64 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "logger.h"
#include <QApplication>
#include <iostream>
using std::cout;
Logger* Logger::instance (new Logger());
void gfLog(QString text)
{
cout << text.toStdString() << "\n";
Logger::instance->emitTextLogged(text, QTextCharFormat());
}
void gfError(QString text)
{
cout << "E: " << text.toStdString() << "\n";
QTextCharFormat f;
f.setForeground(QColor(255,0,0));
//f.setTextOutline(QPen( QColor(255,170,170,80) , 3));
Logger::instance->emitTextLogged(text,f);
}
void gfWarning(QString text)
{
cout << "W: " << text.toStdString() << "\n";
QTextCharFormat f;
f.setForeground(QColor(255,128,0));
Logger::instance->emitTextLogged(text,f);
}
void gfSuccess(QString text)
{
cout << "S: " << text.toStdString() << "\n";
QTextCharFormat f;
f.setForeground(QColor(0,180,0));
Logger::instance->emitTextLogged(text,f);
}
void gfInfo(QString text)
{
cout << "I: " << text.toStdString() << "\n";
QTextCharFormat f;
f.setForeground(QColor(150,150,150));
Logger::instance->emitTextLogged(text,f);
}
Logger::Logger(QObject *parent) : QObject(parent)
{
// Does nothing, only fires signals
instance = this;
}
void Logger::emitTextLogged(QString text, QTextCharFormat format)
{
emit LogText(text, format);
//entries.append( QPair< QString, QTextCharFormat> (text, format) );
}
void Logger::gflog(QString text)
{
::gfLog(text);
}
void Logger::gfError(QString text)
{
::gfError(text);
}
void Logger::gfWarning(QString text)
{
::gfWarning(text);
}
void Logger::gfSuccess(QString text)
{
::gfSuccess(text);
}
void Logger::gfInfo(QString text)
{
::gfInfo(text);
}