diff options
| author | Jonathan Bauer | 2011-03-20 19:37:58 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2011-03-20 19:37:58 +0100 |
| commit | 3e76f5ca4439ae87f436080b840dba180fb842d3 (patch) | |
| tree | f02a320058973ec60fa85a84491ce222c513aefd /src/loggerEngine.cpp | |
| parent | debug console dummy only shown if debug mode active (diff) | |
| download | fbgui-3e76f5ca4439ae87f436080b840dba180fb842d3.tar.gz fbgui-3e76f5ca4439ae87f436080b840dba180fb842d3.tar.xz fbgui-3e76f5ca4439ae87f436080b840dba180fb842d3.zip | |
debug console now powered by qxt, custom engines, updated debug msgs. Download manager now uses notify(message) to send error/status to the javascript interface, checks for download errors (still some missing)
Diffstat (limited to 'src/loggerEngine.cpp')
| -rw-r--r-- | src/loggerEngine.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/loggerEngine.cpp b/src/loggerEngine.cpp new file mode 100644 index 0000000..c6c60e4 --- /dev/null +++ b/src/loggerEngine.cpp @@ -0,0 +1,76 @@ +#include "loggerEngine.h" + +loggerEngine_fb::loggerEngine_fb(QTextEdit *parent) : QxtLoggerEngine(){ + _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 */ + /* write the messages to the debug console */ + if (msgs.isEmpty()) return; + Q_FOREACH(const QVariant& out, msgs) + { + if (!out.isNull()) + _debugConsole->insertPlainText(out.toString()); + } + _debugConsole->insertPlainText(QString("\n")); + /* move to end of the document */ + QTextCursor c = _debugConsole->textCursor(); + c.movePosition(QTextCursor::End); + _debugConsole->setTextCursor(c); +} +//---------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------- +loggerEngine_std::loggerEngine_std() : QxtBasicSTDLoggerEngine(){ + setLogLevelsEnabled(QxtLogger::DebugLevel); + enableLogging(); +} +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") + "] [" + str_level + "] "; + 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){ + if (msgs.isEmpty()) return; + QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] [" + level + "] "; + QTextStream* outstream = stdOutStream(); + Q_ASSERT(outstream); + *outstream << header; + Q_FOREACH(const QVariant& out, msgs){ + if (!out.isNull()){ + *outstream << out.toString(); + } + } + *outstream << endl; +} |
