All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.klogging.sending.EventSender.kt Maven / Gradle / Ivy

Go to download

Kotlin logging library with structured logging and coroutines support

The newest version!
package io.klogging.sending

import io.klogging.events.LogEvent
import io.klogging.rendering.RenderString

/** Interface for sending log events somewhere. */
public fun interface EventSender {
    /**
     * Send a batch of log events somewhere.
     *
     * @param batch list of events to send.
     */
    public operator fun invoke(batch: List)
}

/**
 * Convert a [RenderString] and [SendString] into an [EventSender].
 *
 * @param renderer the [RenderString] that renders a log event into a string
 * @param sender the [SendString] that sends the rendered event string somewhere
 */
public fun senderFrom(renderer: RenderString, sender: SendString): EventSender =
    EventSender { batch -> sender(batch.joinToString("\n") { renderer(it) }) }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy