-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.h
44 lines (40 loc) · 1.13 KB
/
logger.h
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
#pragma once
#include <ktexteditor/mainwindow.h>
#include <qcontainerfwd.h>
#include <qobject.h>
#include <qstringliteral.h>
#include <QVariantMap>
class Logger
{
public:
enum Type {
DEBUG,
INFO,
WARN,
ERROR,
};
static void Log(Type type, const QString &msg, KTextEditor::MainWindow *mainWindow)
{
QString typeStr;
switch (type) {
case DEBUG:
typeStr = QStringLiteral("Debug");
break;
case INFO:
typeStr = QStringLiteral("Info");
break;
case WARN:
typeStr = QStringLiteral("Warning");
break;
case ERROR:
typeStr = QStringLiteral("Error");
break;
}
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("category"), QStringLiteral("Text Highlight"));
genericMessage.insert(QStringLiteral("text"), msg);
genericMessage.insert(QStringLiteral("type"), typeStr);
genericMessage.insert(QStringLiteral("type"), QStringLiteral("yourmessagetoken"));
mainWindow->showMessage(genericMessage);
}
};