From c0b6b199a9878bc1e95907200501211c09c1e66c Mon Sep 17 00:00:00 2001 From: Niklas Goby Date: Wed, 23 Nov 2011 11:56:19 +0100 Subject: created modules --- src/loggerengine.cpp | 116 --------------------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 src/loggerengine.cpp (limited to 'src/loggerengine.cpp') diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp deleted file mode 100644 index 8a0991d..0000000 --- a/src/loggerengine.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "loggerengine.h" - -// -------------------------------------------------------------------------------------------------- -// base of a custom logger engine for the framebuffer -//--------------------------------------------------------------------------------------------------- -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, bool) { - //QxtLoggerEngine::setLogLevelsEnabled(level, enable); - //if (!enable) QxtLoggerEngine::setLogLevelsEnabled(QxtLogger::DebugLevel); -} -bool LoggerEngine_fb::isInitialized() const { - //return _initialized; - return true; -} - -void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList & msgs) { - - // ignore in case no messages was passed. - if (msgs.isEmpty()) - return; - - // write timestamp header in format: [hh:mm:ss.zzz] - // example: [23:58:99.999] - QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; - _debugConsole->insertPlainText(header); - - // only write to console for debug level - if (level == QxtLogger::DebugLevel) { - 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); - } -} -//--------------------------------------------------------------------------------------------------- -// slighty modified QxtBasicSTDLoggerEngine -//--------------------------------------------------------------------------------------------------- -LoggerEngine_std::LoggerEngine_std() : - QxtBasicSTDLoggerEngine() { -} - -LoggerEngine_std::~LoggerEngine_std() { -} - -void LoggerEngine_std::writeToStdErr(const QString&, 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&, const QList &) { - // (level, msgs) - // reimplementing this is needed for compiling, - // we only need write to std::err, so this function is not needed -} -//--------------------------------------------------------------------------------------------------- -// slighty modified QxtBasicFileLoggerEngine -//--------------------------------------------------------------------------------------------------- -LoggerEngine_file::LoggerEngine_file(const QString& logFileName) : - QxtBasicFileLoggerEngine(logFileName) { - //setLogFileName(logFileName); -} - -LoggerEngine_file::~LoggerEngine_file() { -} - -void LoggerEngine_file::initLoggerEngine() { -} - -void LoggerEngine_file::writeToFile(const QString&, const QList &msgs) { - - if (msgs.isEmpty()) - return; - QIODevice* file = device(); - QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; - file->write(header.toUtf8()); - Q_FOREACH(const QVariant& out, msgs) - { - if (!out.isNull()) - file->write(out.toString().toUtf8()); - } - file->write("\n"); -} -- cgit v1.2.3-55-g7522