commonMain.lexi.ConsoleConfigurationUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lexi-console Show documentation
Show all versions of lexi-console Show documentation
A kotlin multiplatform solution to logging on the console
The newest version!
package lexi
fun Map.toConsoleAppenderOptions(): ConsoleAppenderOptions = ConsoleAppenderOptions(
level = LogLevel.parse(getOrElse("level") { "DEBUG" }) ?: LogLevel.DEBUG,
verbose = getOrElse("verbose") { "true" }.toBoolean(),
formatter = when (val formatter = getOrElse("formatter") { "simple" }) {
"simple" -> SimpleLogFormatter(toSimpleFormatterOptions())
"json" -> JsonLogFormatter(toJsonFormatterOptions())
else -> throw IllegalArgumentException("Unknown formatter type: $formatter")
}
)
fun Map.toConsoleAppender() = ConsoleAppender(toConsoleAppenderOptions())