Skip to content

Commit

Permalink
debug: Add extra debug logging along Gradle analysis path
Browse files Browse the repository at this point in the history
  • Loading branch information
elldritch committed Jan 11, 2024
1 parent 64c2f20 commit 76a47d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/App/Fossa/Analyze.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import Effect.Exec (Exec)
import Effect.Logger (
Logger,
Severity (..),
logDebug,
logInfo,
logStdout,
)
Expand Down Expand Up @@ -353,8 +354,10 @@ analyze cfg = Diag.context "fossa-analyze" $ do
forkTask $ do
res <- Diag.runDiagnosticsIO . diagToDebug . stickyLogStack . withEmptyStack $ Archive.discover (runAnalyzers filters) basedir ancestryDirect
Diag.withResult SevError SevWarn res (const (pure ()))
logDebug $ "Unfiltered project scans: " <> pretty (show projectScans)

let filteredProjects = mapMaybe toProjectResult projectScans
logDebug $ "Filtered project scans: " <> pretty (show projectScans)

maybeEndpointAppVersion <- case destination of
UploadScan apiOpts _ -> runFossaApiClient apiOpts $ do
Expand All @@ -377,6 +380,7 @@ analyze cfg = Diag.context "fossa-analyze" $ do
$ traverse (enrichPathDependencies includeAll vendoredDepsOptions revision) filteredProjects
(True, _) -> pure $ map enrichPathDependencies' filteredProjects
(False, _) -> traverse (withPathDependencyNudge includeAll) filteredProjects
logDebug $ "Filtered projects with path dependencies: " <> pretty (show filteredProjects')

let analysisResult = AnalysisScanResult projectScans vsiResults binarySearchResults manualSrcUnits dynamicLinkedResults maybeLernieResults
renderScanSummary (severity cfg) maybeEndpointAppVersion analysisResult $ Config.filterSet cfg
Expand All @@ -390,6 +394,7 @@ analyze cfg = Diag.context "fossa-analyze" $ do
(Just firstParty, Nothing) -> Just firstParty
let keywordSearchResultsFound = (maybe False (not . null . lernieResultsKeywordSearches) lernieResults)
let outputResult = buildResult includeAll additionalSourceUnits filteredProjects' licenseSourceUnits
logDebug $ "Source unit result: " <> pretty (show outputResult)

-- If we find nothing but keyword search, we exit with an error, but explain that the error may be ignorable.
-- We do not want to succeed, because nothing gets uploaded to the API for keyword searches, so `fossa test` will fail.
Expand Down
2 changes: 2 additions & 0 deletions src/Strategy/Gradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ analyze foundTargets dir = withSystemTempDir "fossa-gradle" $ \tmpDir -> do

let text = decodeUtf8 $ BL.toStrict stdout
let resolvedProjects = ResolutionApi.parseResolutionApiJsonDeps text
logDebug $ "Resolved projects: " <> pretty (show resolvedProjects)
let graphFromResolutionApi = ResolutionApi.buildGraph resolvedProjects (onlyConfigurations)
logDebug $ "Graph: " <> pretty (show graphFromResolutionApi)

-- Log debug messages as seen in gradle script
traverse_ (logDebug . pretty) (getDebugMessages text)
Expand Down

0 comments on commit 76a47d0

Please sign in to comment.