From 3e76f5ca4439ae87f436080b840dba180fb842d3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 20 Mar 2011 19:37:58 +0100 Subject: 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) --- src/loggerEngine.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 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..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 & 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 &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 & 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; +} -- cgit v1.2.3-55-g7522