summaryrefslogtreecommitdiffstats
path: root/src/loggerengine.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-21 11:48:32 +0100
committerJonathan Bauer2011-03-21 11:48:32 +0100
commit31050528017e11c54f408b22c92265ff6c4c4b69 (patch)
treeb3a83fc05f53548a7c6beb29b9b0d971b9c49cc3 /src/loggerengine.cpp
parentminor code convention fixes (diff)
downloadfbgui-31050528017e11c54f408b22c92265ff6c4c4b69.tar.gz
fbgui-31050528017e11c54f408b22c92265ff6c4c4b69.tar.xz
fbgui-31050528017e11c54f408b22c92265ff6c4c4b69.zip
and the files ^^
Diffstat (limited to 'src/loggerengine.cpp')
-rw-r--r--src/loggerengine.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp
new file mode 100644
index 0000000..5638908
--- /dev/null
+++ b/src/loggerengine.cpp
@@ -0,0 +1,67 @@
+#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;
+}
+
+void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList<QVariant> & msgs){
+ // TODO: handle different log levels
+ if (msgs.isEmpty()) return;
+ 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
+}