summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Bauer2011-04-24 16:59:50 +0200
committerJonathan Bauer2011-04-24 16:59:50 +0200
commit51a1b87480973792fcadb35767d7b61f32d12df9 (patch)
tree401e398cd7627f1578179cea7582c98f361b8941 /src
parentdm thread ending properly now, few fixes (diff)
downloadfbgui-51a1b87480973792fcadb35767d7b61f32d12df9.tar.gz
fbgui-51a1b87480973792fcadb35767d7b61f32d12df9.tar.xz
fbgui-51a1b87480973792fcadb35767d7b61f32d12df9.zip
auto-close removed, handled by fbgui nowmake
Diffstat (limited to 'src')
-rw-r--r--src/loggerengine.cpp51
-rw-r--r--src/loggerengine.h13
-rw-r--r--src/main.cpp9
3 files changed, 59 insertions, 14 deletions
diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp
index 51fba62..3a44159 100644
--- a/src/loggerengine.cpp
+++ b/src/loggerengine.cpp
@@ -32,8 +32,8 @@ bool LoggerEngine_fb::isInitialized() const {
return true;
}
-void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList<
- QVariant> & msgs) {
+void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level,
+ const QList<QVariant> & msgs) {
// ignore in case no messages was passed.
if (msgs.isEmpty())
@@ -47,10 +47,10 @@ void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList<
// only write to console for debug level
if (level == QxtLogger::DebugLevel) {
Q_FOREACH(const QVariant& out, msgs)
- {
- if (!out.isNull())
- _debugConsole->insertPlainText(out.toString());
- }
+ {
+ if (!out.isNull())
+ _debugConsole->insertPlainText(out.toString());
+ }
_debugConsole->insertPlainText(QString("\n"));
// autoscroll
QTextCursor c = _debugConsole->textCursor();
@@ -68,8 +68,8 @@ LoggerEngine_std::LoggerEngine_std() :
LoggerEngine_std::~LoggerEngine_std() {
}
-void LoggerEngine_std::writeToStdErr(const QString& str_level, const QList<
- QVariant> &msgs) {
+void LoggerEngine_std::writeToStdErr(const QString& str_level,
+ const QList<QVariant> &msgs) {
if (msgs.isEmpty())
return;
@@ -78,10 +78,10 @@ void LoggerEngine_std::writeToStdErr(const QString& str_level, const QList<
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,
@@ -89,3 +89,30 @@ void LoggerEngine_std::writeToStdOut(const QString& level,
// 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() :
+ QxtBasicFileLoggerEngine() {
+}
+
+LoggerEngine_file::~LoggerEngine_file() {
+}
+
+LoggerEngine_file::initLoggerEngine() {}
+
+void LoggerEngine_file::writeToFile(const QString& str_level,
+ const QList<QVariant> &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");
+}
diff --git a/src/loggerengine.h b/src/loggerengine.h
index 95a8f93..45f6827 100644
--- a/src/loggerengine.h
+++ b/src/loggerengine.h
@@ -49,9 +49,20 @@ public:
LoggerEngine_std();
~LoggerEngine_std();
- // reimplemented virtual functions of QxtBasicSTDLoggerEngineqqq
+ // reimplemented virtual functions of QxtBasicSTDLoggerEngine
void writeToStdOut(const QString& level, const QList<QVariant> &msgs);
void writeToStdErr(const QString& str_level, const QList<QVariant> &msgs);
};
+//---------------------------------------------------------------------------------------------------
+// slighty modified QxtBasicFileLoggerEngine
+//---------------------------------------------------------------------------------------------------
+class LoggerEngine_file: public QxtBasicFileLoggerEngine {
+public:
+ LoggerEngine_file();
+ ~LoggerEngine_file();
+
+ // reimplemented virtual functions of QxtBasicFileLoggerEngine
+ void writeToFile(const QString& level, const QList<QVariant> &msgs);
+};
#endif // LOGGERENGINE_H_
diff --git a/src/main.cpp b/src/main.cpp
index 9b0a18a..601a62e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -88,13 +88,20 @@ int main(int argc, char *argv[]) {
if (clOpts.contains("debug")) {
debugMode = clOpts.value("debug").toInt();
- // start basic debug log
+ // start basic debug output on terminal
qxtLog->disableLoggerEngine("DEFAULT");
qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std);
qxtLog->initLoggerEngine("std_logger");
qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel);
qxtLog->enableLogLevels(QxtLogger::DebugLevel);
qxtLog->debug() << "Initializing fbgui...";
+ // start debug logging to file.
+ qxtLog->addLoggerEngine("file_logger", new LoggerEngine_file);
+
+ //qxtLog->initLoggerEngine("std_logger");
+ //qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel);
+ //qxtLog->enableLogLevels(QxtLogger::DebugLevel);
+
} else
debugMode = -1;