You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix SLF4J conflict with Kotlin scripting, default log level (#203)
In #178, logging was changed to SLF4J and logback-classic. To keep it
possible to set the log level via environment variables
(`Config.logLevel` / `DEVELOCITY_API_LOG_LEVEL`), a small hack was in
place. Kotlin scripts, [which have `slf4j-simple` in the classpath by
default][1], crashed due to this hack.
```
java.lang.ClassCastException: class org.slf4j.impl.SimpleLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.impl.SimpleLogger is in unnamed module of loader java.net.URLClassLoader @3a0f0552; ch.qos.logback.classic.Logger is in unnamed module of loader java.net.URLClassLoader @47b530e0)
at com.gabrielfeo.develocity.api.internal.RealLoggerFactory.newLogger(LoggerFactory.kt:17)
at com.gabrielfeo.develocity.api.internal.OkHttpClientKt.addNetworkInterceptors(OkHttpClient.kt:61)
at com.gabrielfeo.develocity.api.internal.OkHttpClientKt.buildOkHttpClient(OkHttpClient.kt:35)
at com.gabrielfeo.develocity.api.RealDevelocityApi$okHttpClient$2.invoke(DevelocityApi.kt:72)
at com.gabrielfeo.develocity.api.RealDevelocityApi$okHttpClient$2.invoke(DevelocityApi.kt:71)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.gabrielfeo.develocity.api.RealDevelocityApi.getOkHttpClient(DevelocityApi.kt:71)
at com.gabrielfeo.develocity.api.RealDevelocityApi.access$getOkHttpClient(DevelocityApi.kt:67)
at com.gabrielfeo.develocity.api.RealDevelocityApi$retrofit$2.invoke(DevelocityApi.kt:78)
at com.gabrielfeo.develocity.api.RealDevelocityApi$retrofit$2.invoke(DevelocityApi.kt:75)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.gabrielfeo.develocity.api.RealDevelocityApi.getRetrofit(DevelocityApi.kt:75)
at com.gabrielfeo.develocity.api.RealDevelocityApi.access$getRetrofit(DevelocityApi.kt:67)
at com.gabrielfeo.develocity.api.RealDevelocityApi$buildsApi$2.invoke(DevelocityApi.kt:84)
at com.gabrielfeo.develocity.api.RealDevelocityApi$buildsApi$2.invoke(DevelocityApi.kt:84)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.gabrielfeo.develocity.api.RealDevelocityApi.getBuildsApi(DevelocityApi.kt:84)
at Example_script_main$builds$1.invokeSuspend(example-script.main.kts:39)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:48)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at Example_script_main.<init>(example-script.main.kts:38)
```
Also, the default log level was 'info', but it was supposed to be 'off'.
- Remove logback and any reference to SLF4J impls
- Add `slf4j-simple` instead with a simpler hack ✨ to set the log level
from environment variables
- Fix the default log level to be 'off', unless it'd conflict with the
user's own SimpleLogger default
- Document what the llbrary logs on each log level
[1]:
https://github.com/JetBrains/kotlin/blob/27c6d00cb2a5f9c0e9df62b021600e1263f5201a/libraries/tools/kotlin-main-kts/build.gradle.kts#L44
0 commit comments