Index: sources/storage/Logger.cpp =================================================================== diff -u -r2216ac6ac7f77437a7c29ac8b4043be01bc4609e -r6816b783f50e08267aa016d64350bc020080d901 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 2216ac6ac7f77437a7c29ac8b4043be01bc4609e) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 6816b783f50e08267aa016d64350bc020080d901) @@ -57,8 +57,8 @@ checkLogPath(); initConnections(); - LOG_EVENT("--------------------------------------------------\n" - "UI," + tr("%1 Initialized").arg(metaObject()->className())); + ADD_EVENT_HEADER; + LOG_DEBUG("UI," + tr("%1 Initialized").arg(metaObject()->className())); return true; } @@ -105,8 +105,8 @@ connect(&_exportLogsWatcher, SIGNAL(finished ()), this , SLOT(onExportLogs())); - connect(this, SIGNAL(didLog(QString,LogType)), - this, SLOT( onLog(QString,LogType))); + connect(this, SIGNAL(didLog(QString,LogType,bool)), + this, SLOT( onLog(QString,LogType,bool))); connect(&_MainTimer, SIGNAL( didDateChange ()), this , SLOT( concurrentRemoveLogs())); @@ -154,9 +154,9 @@ } // coco end -void Logger::onLog(const QString &vContent, LogType vLogType) +void Logger::onLog(const QString &vContent, LogType vLogType, bool vTimestamp) { - log(vContent,vLogType); + log(vContent, vLogType, vTimestamp); } /*! @@ -231,6 +231,7 @@ break; } ok = FileHandler::makeFolder(_logPathNames[vLogType]); + if ( ok ) emit didLogPathSet(vLogType, _logPathNames[vLogType]); return ok; } @@ -242,9 +243,17 @@ * \note This method is not thread-safe so is private and needs to be called by concurrentLog * Which uses QtConcurrent::run to run in thread and thread-safe. */ -void Logger::log(const QString &vContent, LogType vLogType) +void Logger::log(const QString &vContent, LogType vLogType, bool vTimestamp) { - QString date = QDate::currentDate().toString(_dateFormat); + static QString date; + QString currentDate = QDate::currentDate().toString(_dateFormat); + if (date != currentDate) { + if (!date.isEmpty()) { + ADD_EVENT_HEADER; + } + date = currentDate; + } + QString fileName = date + _dateSeparator + _logFileNamePrefix; switch (vLogType) { case LogType::eLogEvent: @@ -259,10 +268,12 @@ LOG_DEBUG(QString("Incorrect type of logging %1").arg(vLogType)); } - QString mContent = QTime::currentTime().toString(_timeFormat) + _separator; + QString mContent; + if ( vTimestamp ) + mContent = QTime::currentTime().toString(_timeFormat) + _separator; QString logPrefix = _logPrefix[vLogType]; - if ( ! logPrefix.isEmpty()) { + if (vTimestamp && ! logPrefix.isEmpty()) { mContent += logPrefix; mContent += _separator; } @@ -469,4 +480,9 @@ LOG_DEBUG("Console out Logging disabled"); } } + +const QString &Logger::logPath(Logger::LogType vLogType) +{ + return _logPathNames[vLogType]; +} // coco end