Skip to content

Commit

Permalink
Harmonize logging
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverO2 committed May 13, 2024
1 parent ee38628 commit 6b718f1
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class Discovery(

private fun doDiscovery(request: DiscoveryRequest): Result<DiscoveryResult> = runCatching {

log { "[Discovery] Starting spec discovery" }

val specsSelected = request.specsIfCompletelySpecifiedOrNull()
?: cachedSpecsFromClassPaths
.asSequence()
Expand All @@ -86,14 +88,10 @@ class Discovery(
.filter(selectorFn(request.selectors))
.toList()

log { "[Discovery] Selected ${specsSelected.size} specs" }

val specsAfterInitialFiltering = specsSelected.filter(filterFn(request.filters))

log { "[Discovery] ${specsAfterInitialFiltering.size} specs remain after initial filtering" }

log { "[Discovery] Further filtering classes via discovery extensions [$discoveryExtensions]" }

val specsAfterExtensionFiltering = discoveryExtensions
.fold(specsAfterInitialFiltering) { cl, ext -> ext.afterScan(cl) }
.sortedBy { it.simpleName }
Expand All @@ -112,7 +110,6 @@ class Discovery(
if (selectors.isEmpty() || !selectors.all { it is DiscoverySelector.ClassDiscoverySelector })
return null

log { "[Discovery] Collecting specs via class discovery selectors..." }
val start = System.currentTimeMillis()

// first filter down to spec instances only, then load the full class
Expand All @@ -128,7 +125,7 @@ class Discovery(

log {
val duration = System.currentTimeMillis() - start
"[Discovery] Collecting specs via class discovery selectors completed in ${duration}ms," +
"[Discovery] Collected specs via ${selectors.size} class discovery selectors in ${duration}ms," +
" found ${specs.size} specs"
}

Expand All @@ -140,8 +137,6 @@ class Discovery(
* locations specified by the uris param.
*/
private fun specsFromClassGraph(): List<KClass<out Spec>> {
log { "[Discovery] Starting classgraph scan for specs..." }

val start = System.currentTimeMillis()
val specs = classgraph().scan().use { scanResult ->
scanResult
Expand All @@ -152,7 +147,7 @@ class Discovery(

log {
val duration = System.currentTimeMillis() - start
"[Discovery] Completed classgraph scan for specs in ${duration}ms, found ${specs.size} specs"
"[Discovery] Scanned classgraph for specs in ${duration}ms, found ${specs.size} specs"
}

return specs
Expand Down

0 comments on commit 6b718f1

Please sign in to comment.