From 31050528017e11c54f408b22c92265ff6c4c4b69 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 21 Mar 2011 11:48:32 +0100 Subject: and the files ^^ --- src/loggerengine.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/loggerengine.cpp (limited to 'src/loggerengine.cpp') 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 & 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 &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 & msgs){ + // reimplementing this is needed for compiling, + // we only need write to std::err, so this function is not needed +} -- cgit v1.2.3-55-g7522