forked from qt-creator/qt-creator
		
	CppTools: Encode more information in log file of CppCodeModelInspector
Among others the timestamp and if provided, some extra id. Change-Id: I017c2af197023347c88f2547e7bda8f22b3d00c4 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
		@@ -421,11 +421,25 @@ QList<CPlusPlus::Document::Ptr> Utils::snapshotToList(const CPlusPlus::Snapshot
 | 
			
		||||
    return documents;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Dumper::Dumper(const CPlusPlus::Snapshot &globalSnapshot)
 | 
			
		||||
Dumper::Dumper(const CPlusPlus::Snapshot &globalSnapshot, const QString &logFileId)
 | 
			
		||||
    : m_globalSnapshot(globalSnapshot), m_out(stderr)
 | 
			
		||||
{
 | 
			
		||||
    const QString logFileName = QDir::tempPath()
 | 
			
		||||
        + QString::fromLatin1("/qtc-codemodelinspection.txt");
 | 
			
		||||
    QString ideRevision;
 | 
			
		||||
#ifdef IDE_REVISION
 | 
			
		||||
     ideRevision = QString::fromLatin1(Core::Constants::IDE_REVISION_STR).left(10);
 | 
			
		||||
#endif
 | 
			
		||||
    QString ideRevision_ = ideRevision;
 | 
			
		||||
    if (!ideRevision_.isEmpty())
 | 
			
		||||
        ideRevision_.prepend(QLatin1Char('_'));
 | 
			
		||||
    QString logFileId_ = logFileId;
 | 
			
		||||
    if (!logFileId_.isEmpty())
 | 
			
		||||
        logFileId_.prepend(QLatin1Char('_'));
 | 
			
		||||
    const QString logFileName = QDir::tempPath() + QString::fromLatin1("/qtc-codemodelinspection")
 | 
			
		||||
            + ideRevision_
 | 
			
		||||
            + QDateTime::currentDateTime().toString(QLatin1String("_yyMMdd_hhmmss"))
 | 
			
		||||
            + logFileId_
 | 
			
		||||
            + QLatin1String(".txt");
 | 
			
		||||
 | 
			
		||||
    m_logFile.setFileName(logFileName);
 | 
			
		||||
    if (m_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
 | 
			
		||||
        m_out << "Code model inspection log file is \"" << QDir::toNativeSeparators(logFileName)
 | 
			
		||||
@@ -433,12 +447,7 @@ Dumper::Dumper(const CPlusPlus::Snapshot &globalSnapshot)
 | 
			
		||||
        m_out.setDevice(&m_logFile);
 | 
			
		||||
    }
 | 
			
		||||
    m_out << "*** START Code Model Inspection Report for ";
 | 
			
		||||
    QString ideRevision;
 | 
			
		||||
#ifdef IDE_REVISION
 | 
			
		||||
     ideRevision = QLatin1String(" from revision ")
 | 
			
		||||
        + QString::fromLatin1(Core::Constants::IDE_REVISION_STR).left(10);
 | 
			
		||||
#endif
 | 
			
		||||
    m_out << Core::ICore::versionString() << ideRevision << "\n";
 | 
			
		||||
    m_out << Core::ICore::versionString() << " from revision " << ideRevision << "\n";
 | 
			
		||||
    m_out << "Note: This file contains vim fold markers (\"{{{n\"). "
 | 
			
		||||
             "Make use of them via \":set foldmethod=marker\".\n";
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -64,7 +64,8 @@ struct CPPTOOLS_EXPORT Utils
 | 
			
		||||
class CPPTOOLS_EXPORT Dumper
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    explicit Dumper(const CPlusPlus::Snapshot &globalSnapshot);
 | 
			
		||||
    explicit Dumper(const CPlusPlus::Snapshot &globalSnapshot,
 | 
			
		||||
                    const QString &logFileId = QString());
 | 
			
		||||
    ~Dumper();
 | 
			
		||||
 | 
			
		||||
    void dumpProjectInfos(const QList<CppTools::CppModelManagerInterface::ProjectInfo> &projectInfos);
 | 
			
		||||
 
 | 
			
		||||
@@ -406,13 +406,13 @@ QByteArray CppModelManager::internalDefinedMacros() const
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// This function will acquire mutexes!
 | 
			
		||||
void CppModelManager::dumpModelManagerConfiguration()
 | 
			
		||||
void CppModelManager::dumpModelManagerConfiguration(const QString &logFileId)
 | 
			
		||||
{
 | 
			
		||||
    const Snapshot globalSnapshot = snapshot();
 | 
			
		||||
    const QString globalSnapshotTitle
 | 
			
		||||
        = QString::fromLatin1("Global/Indexing Snapshot (%1 Documents)").arg(globalSnapshot.size());
 | 
			
		||||
 | 
			
		||||
    CppCodeModelInspector::Dumper dumper(globalSnapshot);
 | 
			
		||||
    CppCodeModelInspector::Dumper dumper(globalSnapshot, logFileId);
 | 
			
		||||
    dumper.dumpProjectInfos(projectInfos());
 | 
			
		||||
    dumper.dumpSnapshot(globalSnapshot, globalSnapshotTitle, /*isGlobalSnapshot=*/ true);
 | 
			
		||||
    dumper.dumpWorkingCopy(workingCopy());
 | 
			
		||||
@@ -742,7 +742,7 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
 | 
			
		||||
 | 
			
		||||
    // If requested, dump everything we got
 | 
			
		||||
    if (DumpProjectInfo)
 | 
			
		||||
        dumpModelManagerConfiguration();
 | 
			
		||||
        dumpModelManagerConfiguration(QLatin1String("updateProjectInfo"));
 | 
			
		||||
 | 
			
		||||
    // Remove files from snapshot that are not reachable any more
 | 
			
		||||
    if (filesRemoved)
 | 
			
		||||
 
 | 
			
		||||
@@ -187,7 +187,7 @@ private:
 | 
			
		||||
    QStringList internalFrameworkPaths() const;
 | 
			
		||||
    QByteArray internalDefinedMacros() const;
 | 
			
		||||
 | 
			
		||||
    void dumpModelManagerConfiguration();
 | 
			
		||||
    void dumpModelManagerConfiguration(const QString &logFileId);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    static QMutex m_instanceMutex;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user