From d8f5457f901f460290128ab8e23daca3baf2d9d4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 31 Jul 2017 10:44:04 +0200 Subject: Use categorized logging for the input artifact scanner Change-Id: I3419b1dca7b39f6bc95c8d73aae57703ef4cf5c0 Reviewed-by: Christian Kandeler --- .../corelib/buildgraph/inputartifactscanner.cpp | 59 +++++++--------------- 1 file changed, 18 insertions(+), 41 deletions(-) (limited to 'src/lib/corelib/buildgraph/inputartifactscanner.cpp') diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp index 6c7717e90..89d6bde93 100644 --- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp +++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp @@ -48,6 +48,7 @@ #include "rulesevaluationcontext.h" #include +#include #include #include #include @@ -121,13 +122,8 @@ void InputArtifactScanner::scan() if (m_artifact->inputsScanned) return; - if (m_logger.traceEnabled()) { - m_logger.qbsTrace() - << QString::fromLatin1("[DEPSCAN] inputs for %1 [%2] in product '%3'") - .arg(m_artifact->filePath(), - m_artifact->fileTags().toStringList().join(QLatin1String(", ")), - m_artifact->product->name); - } + qCDebug(lcDepScan) << "scan inputs for" << m_artifact->filePath() << m_artifact->fileTags() + << "in product" << m_artifact->product->name; m_artifact->inputsScanned = true; @@ -147,12 +143,8 @@ void InputArtifactScanner::scan() void InputArtifactScanner::scanForFileDependencies(Artifact *inputArtifact) { - if (m_logger.traceEnabled()) { - m_logger.qbsTrace() - << QString::fromLatin1("[DEPSCAN] input artifact %1 [%2]") - .arg(inputArtifact->filePath(), - inputArtifact->fileTags().toStringList().join(QLatin1String(", "))); - } + qCDebug(lcDepScan) << "input artifact" << inputArtifact->filePath() + << inputArtifact->fileTags(); InputArtifactScannerContext::CacheItem &cacheItem = m_context->cache[inputArtifact->properties]; Set visitedFilePaths; @@ -210,30 +202,23 @@ void InputArtifactScanner::scanForScannerFileDependencies(DependencyScanner *sca QList *filesToScan, InputArtifactScannerContext::ScannerResolvedDependenciesCache &cache) { - if (m_logger.traceEnabled()) { - m_logger.qbsTrace() << QString::fromLatin1("[DEPSCAN] file %1") - .arg(fileToBeScanned->filePath()); - } + qCDebug(lcDepScan) << "file" << fileToBeScanned->filePath(); const bool cacheHit = cache.valid; if (!cacheHit) { cache.valid = true; cache.searchPaths = scanner->collectSearchPaths(inputArtifact); } - if (m_logger.traceEnabled()) { - m_logger.qbsTrace() - << "[DEPSCAN] include paths (cache " << (cacheHit ? "hit)" : "miss)"); - for (const QString &s : qAsConst(cache.searchPaths)) - m_logger.qbsTrace() << " " << s; - } + qCDebug(lcDepScan) << "include paths (cache" << (cacheHit ? "hit)" : "miss)"); + for (const QString &s : qAsConst(cache.searchPaths)) + qCDebug(lcDepScan) << " " << s; const QString &filePathToBeScanned = fileToBeScanned->filePath(); RawScanResults::ScanData &scanData = m_rawScanResults.findScanData(fileToBeScanned, scanner, m_artifact->properties); if (scanData.lastScanTime < fileToBeScanned->timestamp()) { try { - if (m_logger.traceEnabled()) - m_logger.qbsTrace() << "scanning " << FileInfo::fileName(filePathToBeScanned); + qCDebug(lcDepScan) << "scanning" << FileInfo::fileName(filePathToBeScanned); scanWithScannerPlugin(scanner, fileToBeScanned, &scanData.rawScanResult); scanData.lastScanTime = FileTime::currentTime(); } catch (const ErrorInfo &error) { @@ -275,8 +260,7 @@ void InputArtifactScanner::resolveScanResultDependencies(const Artifact *inputAr } unresolved: - if (m_logger.traceEnabled()) - m_logger.qbsWarning() << "[DEPSCAN] unresolved dependency " << dependencyFilePath; + qCWarning(lcDepScan) << "unresolved dependency " << dependencyFilePath; continue; resolved: @@ -309,8 +293,7 @@ void InputArtifactScanner::handleDependency(ResolvedDependency &dependency) if (!dependency.file) { // The dependency is an existing file but does not exist in the build graph. - if (m_logger.traceEnabled()) - m_logger.qbsTrace() << "[DEPSCAN] add new file dependency " << dependency.filePath; + qCDebug(lcDepScan) << "add new file dependency" << dependency.filePath; fileDependency = new FileDependency(); dependency.file = fileDependency; @@ -318,23 +301,17 @@ void InputArtifactScanner::handleDependency(ResolvedDependency &dependency) product->topLevelProject()->buildData->insertFileDependency(fileDependency); } else if (fileDependency) { // The dependency exists in the project's list of file dependencies. - if (m_logger.traceEnabled()) { - m_logger.qbsTrace() << "[DEPSCAN] add existing file dependency " - << dependency.filePath; - } + qCDebug(lcDepScan) << "add existing file dependency" << dependency.filePath; } else if (artifactDependency->product == product) { // The dependency is in our product. - if (m_logger.traceEnabled()) { - m_logger.qbsTrace() << "[DEPSCAN] add artifact dependency " << dependency.filePath - << " (from this product)"; - } + qCDebug(lcDepScan) << "add artifact dependency" << dependency.filePath << + "(from this product)"; } else { // The dependency is in some other product. ResolvedProduct * const otherProduct = artifactDependency->product; - if (m_logger.traceEnabled()) { - m_logger.qbsTrace() << "[DEPSCAN] add artifact dependency " << dependency.filePath - << " (from product " << otherProduct->uniqueName() << ')'; - } + qCDebug(lcDepScan) + << "add artifact dependency" << dependency.filePath + << " (from product" << otherProduct->uniqueName() << ')'; } if (m_artifact == dependency.file) -- cgit v1.2.3