Commit fc05dd6
authored
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#L441 parent d27f4b8 commit fc05dd6
File tree
5 files changed
+68
-21
lines changed- library
- src
- main/kotlin/com/gabrielfeo/develocity/api
- internal
- test/kotlin/com/gabrielfeo/develocity/api/internal
5 files changed
+68
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | | - | |
24 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
25 | 34 | | |
26 | 35 | | |
27 | 36 | | |
| |||
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
| 27 | + | |
| 28 | + | |
Lines changed: 3 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 67 | | |
75 | 68 | | |
76 | 69 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
0 commit comments