Skip to content

Commit

Permalink
Refactor logging implementation for coroutines support
Browse files Browse the repository at this point in the history
Eliminated the `SimpleLoggingEvent` and `SimpleCoroutinesLoggingEvent` classes, consolidating logic into a unified `LoggingEvent` class. Introduced comprehensive coroutine-based examples and documentation, enhancing logging with coroutines in Kotlin multiplatform. Updated project version to 0.30.0 and included a new example demonstrating coroutine logging.
  • Loading branch information
smyrgeorge committed Dec 1, 2024
1 parent 89b5e05 commit b38c9b8
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package io.github.smyrgeorge.log4k.impl.extensions

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.asCoroutineDispatcher
import java.util.concurrent.Executors
import kotlinx.coroutines.Dispatchers
import kotlin.reflect.KClass

actual fun KClass<*>.toName(): String =
qualifiedName ?: simpleName ?: error("Could not extract the class-name of $this")

private val dispatcher = Executors.newVirtualThreadPerTaskExecutor().asCoroutineDispatcher()
actual fun dispatcher(): CoroutineDispatcher = dispatcher
actual fun dispatcher(): CoroutineDispatcher = Dispatchers.IO
actual fun thread(): String = Thread.currentThread().name
actual fun threadId(): Int = Thread.currentThread().id.toInt()
actual fun platformPrintlnError(message: String) = println(message)

0 comments on commit b38c9b8

Please sign in to comment.