From e512c756586d5509ac11759bae40f7911fe0f948 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 18 Apr 2011 02:13:18 +0200 Subject: uniformed formatting... --- src/loggerengine.cpp | 102 ++++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 45 deletions(-) (limited to 'src/loggerengine.cpp') diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp index 8f051c8..d37999d 100644 --- a/src/loggerengine.cpp +++ b/src/loggerengine.cpp @@ -3,72 +3,84 @@ // -------------------------------------------------------------------------------------------------- // base of a custom logger engine for the 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(QTextEdit *parent) : + QxtLoggerEngine() { + _debugConsole = parent; + //_initialized = false; + //setLogLevelsEnabled(QxtLogger::DebugLevel); + //enableLogging(); +} +LoggerEngine_fb::~LoggerEngine_fb() { } -LoggerEngine_fb::~LoggerEngine_fb(){} -void LoggerEngine_fb::initLoggerEngine(){ - //_initialized = true; - return; +void LoggerEngine_fb::initLoggerEngine() { + //_initialized = true; + return; } -void LoggerEngine_fb::killLoggerEngine(){ - return; +void LoggerEngine_fb::killLoggerEngine() { + return; } -void LoggerEngine_fb::setLogLevelEnabled(QxtLogger::LogLevels level, bool enable){ +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; - return true; +bool LoggerEngine_fb::isInitialized() const { + //return _initialized; + return true; } -void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList & msgs){ - // TODO: handle different log levels - if (msgs.isEmpty()) return; - 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); - } +void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, + const QList & msgs) { + + if (msgs.isEmpty()) + return; + 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() : + QxtBasicSTDLoggerEngine() { +} -LoggerEngine_std::~LoggerEngine_std(){} +LoggerEngine_std::~LoggerEngine_std() { +} + +void LoggerEngine_std::writeToStdErr(const QString& str_level, + const QList &msgs) { -void LoggerEngine_std::writeToStdErr(const QString& str_level, const QList &msgs){ - if (msgs.isEmpty()) return; - QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; + 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(); - } + { + 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 +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