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

commonMain.kr.jadekim.logger.LogData.kt Maven / Gradle / Ivy

package kr.jadekim.logger

import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import kr.jadekim.logger.context.EmptyLogContext
import kr.jadekim.logger.context.LogContext

interface Log {
    val loggerName: String
    val level: LogLevel
    val message: String
    val throwable: Throwable?
    val meta: Map
    val context: LogContext
    val timestamp: LocalDateTime

    fun isPrintable(level: LogLevel) = this.level.isPrintableAt(level)
}

data class LogData(
    override val loggerName: String,
    override val level: LogLevel,
    override val message: String,
    override val throwable: Throwable? = null,
    override val meta: Map = emptyMap(),
    override val context: LogContext = EmptyLogContext,
    override val timestamp: LocalDateTime = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()),
) : Log

sealed class SerializedLog(log: Log, val data: T) : Log by log {

    class String(log: Log, data: kotlin.String) : SerializedLog(log, data)

    class ByteArray(log: Log, data: kotlin.ByteArray) : SerializedLog(log, data)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy