summaryrefslogtreecommitdiffstats
path: root/src/loggerengine.cpp
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/loggerengine.cpp
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/loggerengine.cpp')
-rw-r--r--src/loggerengine.cpp51
1 files changed, 39 insertions, 12 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");
+}