Index: sources/storage/Logger.cpp =================================================================== diff -u -re159592e3a99658e661ab83fffef43322dc075f3 -r903697f659a275a5be31d05c460dae628f532aab --- sources/storage/Logger.cpp (.../Logger.cpp) (revision e159592e3a99658e661ab83fffef43322dc075f3) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 903697f659a275a5be31d05c460dae628f532aab) @@ -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); } /*! @@ -206,6 +206,7 @@ if ( ok && ! setLogPath(LogType::eLogEvent) ) ok = false; if ( ok && ! setLogPath(LogType::eLogDatum) ) ok = false; if ( ok && ! setLogPath(LogType::eLogDebug) ) ok = false; + if ( ok && ! setLogPath(LogType::eLogTrtmt) ) ok = false; return ok; } // coco end @@ -230,6 +231,7 @@ break; } ok = FileHandler::makeFolder(_logPathNames[vLogType]); + if ( ok ) emit didLogPathSet(vLogType, _logPathNames[vLogType]); return ok; } @@ -241,14 +243,23 @@ * \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: case LogType::eLogDatum: case LogType::eLogDebug: + // case LogType::eLogTrtmt: // this type of log will never happen here. Only put here to make sure it is intentional. fileName += _logFileNameExt[vLogType]; break; @@ -257,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; } @@ -291,7 +304,7 @@ int result = 0; static QString mOSource; QString mDestination = USB_Mount_Point; - for ( const auto &iType : { eLogEvent, eLogDatum } ) { + for ( const auto &iType : { eLogEvent, eLogDatum /*, eLogDebug*/ } ) { QString mCSource = _logPathNames[iType]; // if the event and datum are mixed (mOSource == mCSource) in one file then no need to go over the same files in same folder and do it again. if (mOSource != mCSource) { @@ -350,7 +363,7 @@ static QString mOExtension; int removeCount = 0; QString mLogFileFilter; - for ( const auto &iType : { eLogEvent , eLogDatum , eLogDebug } ) { + for ( const auto &iType : { eLogEvent , eLogDatum , eLogDebug , eLogTrtmt } ) { QString mCSource = _logPathNames [iType]; QString mCExtension = _logFileNameExt[iType]; // if the event and datum are mixed (mOSource == mCSource && mCExtension == mOExtension) in one file then no need to go over the same files in same folder and do it again. @@ -468,3 +481,15 @@ } } // coco end + +/*! + * \brief Logger::logPath + * \details The accessor of the log path for each log type. + * \param vLogType - type of the log + * \return the log path of the log type vLogType as string + * \sa Logger::LogType + */ +const QString &Logger::logPath(Logger::LogType vLogType) +{ + return _logPathNames[vLogType]; +}