diff options
Diffstat (limited to 'src/loggerengine.cpp')
| -rw-r--r-- | src/loggerengine.cpp | 51 |
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"); +} |
