diff options
| author | Niklas Goby | 2011-03-21 12:03:04 +0100 |
|---|---|---|
| committer | Niklas Goby | 2011-03-21 12:03:04 +0100 |
| commit | f2b5a82610ea4b9de9ff5f3ae83cd1715e79bc24 (patch) | |
| tree | 7234b2e8f2083fe23193bc1654c70ec395d20b12 /src/loggerengine.cpp | |
| parent | some changes in the fbgui, ipWatcher (diff) | |
| parent | and the files ^^ (diff) | |
| download | fbgui-f2b5a82610ea4b9de9ff5f3ae83cd1715e79bc24.tar.gz fbgui-f2b5a82610ea4b9de9ff5f3ae83cd1715e79bc24.tar.xz fbgui-f2b5a82610ea4b9de9ff5f3ae83cd1715e79bc24.zip | |
Merge branch 'master' of git.openslx.org:lsfks/master-teamprojekt/fbgui
Conflicts:
src/fbgui.cpp
Diffstat (limited to 'src/loggerengine.cpp')
| -rw-r--r-- | src/loggerengine.cpp | 67 |
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 +} |
