LighthouseGames / KmLogging

Kotlin multiplatform logging. High performance, composable and simple to use.
Apache License 2.0
84 stars 13 forks source link

NullPointerException when logging() on JVM target #19

Closed sgpublic closed 7 months ago

sgpublic commented 1 year ago

Reproduce step:

  1. Clone this repo.
  2. Edit this line: /sample/shared/build.gradle.kts#L29
    api("org.lighthousegames:logging:1.3.0")
  3. Edit this line: /sample/jvmApp/src/jvmMain/kotlin/org/lighthousegames/sample/JvmApp.kt#L35
    val log = logging("test")
  4. Run /sample/jvmApp/src/jvmMain/kotlin/org/lighthousegames/sample/JvmApp.kt

This is the error stacktrace:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.lighthousegames.logging.PlatformLogger.<init>(PlatformLogger.kt:6)
    at org.lighthousegames.logging.KmLoggingKt.<clinit>(KmLogging.kt:11)
    at org.lighthousegames.logging.KmLogKt.logging(KmLog.kt:126)
    at org.lighthousegames.sample.JvmApp.<clinit>(JvmApp.kt:35)
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.concurrent.atomic.AtomicReference.get()" because the return value of "org.lighthousegames.logging.KmLoggingKt.access$getLoggers$p()" is null
    at org.lighthousegames.logging.KmLogging.setupLoggingFlags(KmLogging.kt:82)
    at org.lighthousegames.logging.KmLogging.<clinit>(KmLogging.kt:22)
    ... 4 more
ellsworthrw commented 7 months ago

Fixed in v1.4.2.