Skip to content

Commit

Permalink
Remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mantono committed May 3, 2023
1 parent ff6ffd7 commit b32591e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
5 changes: 0 additions & 5 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ dependencies {
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

// Logging
implementation("io.github.microutils:kotlin-logging-jvm:3.0.5")
testImplementation("net.logstash.logback:logstash-logback-encoder:7.3")
testImplementation("ch.qos.logback:logback-classic:1.4.6")

// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test")

Expand Down
10 changes: 4 additions & 6 deletions lib/src/main/kotlin/io/nexure/capsule/Capsule.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package io.nexure.capsule

import mu.KotlinLogging
import java.lang.reflect.Constructor

private const val DEFAULT_PRIORITY: Int = Int.MAX_VALUE

private val log = KotlinLogging.logger {}

@Suppress("UNCHECKED_CAST")
open class Capsule
private constructor(
Expand All @@ -15,8 +12,10 @@ private constructor(
) : DependencyProvider {
constructor(): this(Int.MAX_VALUE, Registry())

override fun <T : Any> tryGet(clazz: Class<T>): T? =
getDependencies(clazz).firstOrNull()?.let { it.getInstance(this) as T } ?: resolveImplicit(clazz)
override fun <T : Any> tryGet(clazz: Class<T>): T? = resolveExplicit(clazz) ?: resolveImplicit(clazz)

private fun <T : Any> resolveExplicit(clazz: Class<T>): T? =
getDependencies(clazz).firstOrNull()?.let { it.getInstance(this) as T }

private fun <T : Any> resolveImplicit(clazz: Class<T>): T? {
if (clazz in forbiddenImplicit) {
Expand Down Expand Up @@ -74,7 +73,6 @@ private constructor(
val parentsPriority: Int = parents.minOfOrNull { it.priority } ?: DEFAULT_PRIORITY
val priority: Int = parentsPriority - 1
val moduleConfig = Configuration(priority, dependencies).apply(config)
log.debug { "Capsule created with dependencies: ${moduleConfig.dependencies}" }
return Capsule(priority, moduleConfig.dependencies)
}
}
Expand Down

0 comments on commit b32591e

Please sign in to comment.