blob: e6bf402210bddfae0187d46ecd47b82a26818cef (
plain) (
blame)
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
|
#include "loggerengine.h"
// --------------------------------------------------------------------------------------------------
// Custom Logger Engine for debugging on framebuffer
//---------------------------------------------------------------------------------------------------
LoggerEngine_fb::LoggerEngine_fb(QTextEdit *parent) : QxtLoggerEngine(){
// TODO: silly parent storing ... to change!
_debugConsole = parent;
//_initialized = false;
//setLogLevelsEnabled(QxtLogger::DebugLevel);
//enableLogging();
}
LoggerEngine_fb::~LoggerEngine_fb(){}
void LoggerEngine_fb::initLoggerEngine(){
//_initialized = true;
return;
}
void LoggerEngine_fb::killLoggerEngine(){
return;
}
void LoggerEngine_fb::setLogLevelEnabled(QxtLogger::LogLevels level, bool enable){
//QxtLoggerEngine::setLogLevelsEnabled(level, enable);
//if (!enable) QxtLoggerEngine::setLogLevelsEnabled(QxtLogger::DebugLevel);
}
bool LoggerEngine_fb::isInitialized() const{
//return _initialized;
return true;
}
void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList<QVariant> & msgs){
// TODO: handle different log levels
if (msgs.isEmpty()) return;
if (level == QxtLogger::DebugLevel){
Q_FOREACH(const QVariant& out, msgs){
if (!out.isNull())
_debugConsole->insertPlainText(out.toString());
}
_debugConsole->insertPlainText(QString("\n"));
// autoscroll
QTextCursor c = _debugConsole->textCursor();
c.movePosition(QTextCursor::End);
_debugConsole->setTextCursor(c);
}
}
//---------------------------------------------------------------------------------------------------
// Modified QxtBasicSTDLoggerEngine
//---------------------------------------------------------------------------------------------------
LoggerEngine_std::LoggerEngine_std() : QxtBasicSTDLoggerEngine(){}
LoggerEngine_std::~LoggerEngine_std(){}
void LoggerEngine_std::writeToStdErr(const QString& str_level, const QList<QVariant> &msgs){
if (msgs.isEmpty()) return;
QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] ";
QTextStream* errstream = stdErrStream();
Q_ASSERT(errstream);
*errstream << header;
Q_FOREACH(const QVariant& out, msgs)
{
if (!out.isNull())
*errstream << out.toString();
}
*errstream << endl;
}
void LoggerEngine_std::writeToStdOut(const QString& level, const QList<QVariant> & msgs){
// reimplementing this is needed for compiling,
// we only need write to std::err, so this function is not needed
}
|