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

linux.korlibs.logger.Logger.linux.kt Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
@file:OptIn(ExperimentalForeignApi::class)

package korlibs.logger

import kotlinx.cinterop.*

actual object Console : BaseConsole()

actual object DefaultLogOutput : Logger.Output {
    override fun output(logger: Logger, level: Logger.Level, msg: Any?) = Logger.ConsoleLogOutput.output(logger, level, msg)
}

internal actual val miniEnvironmentVariables: Map by lazy {
    getEnvs()
}

private fun getEnvs(): Map {
    val out = LinkedHashMap()
    val env = platform.posix.__environ
    var n = 0
    while (true) {
        val line = env?.get(n++)?.toKString()
        if (line == null || line.isNullOrBlank()) break
        val parts = line.split('=', limit = 2)
        out[parts[0]] = parts.getOrElse(1) { parts[0] }
    }
    return out
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy