[skip ci] Formatting
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
plugins {
|
||||
id(libs.plugins.kotlin.jvm.get().pluginId)
|
||||
id(libs.plugins.kotlin.serialization.get().pluginId)
|
||||
id(libs.plugins.ktlint.get().pluginId)
|
||||
id(
|
||||
libs.plugins.kotlin.jvm
|
||||
.get()
|
||||
.pluginId,
|
||||
)
|
||||
id(
|
||||
libs.plugins.kotlin.serialization
|
||||
.get()
|
||||
.pluginId,
|
||||
)
|
||||
id(
|
||||
libs.plugins.ktlint
|
||||
.get()
|
||||
.pluginId,
|
||||
)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -47,11 +47,10 @@ open class ConfigManager {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : ConfigModule> module(type: Class<T>): T = loadedModules[type] as T
|
||||
|
||||
private fun getUserConfig(): Config {
|
||||
return userConfigFile.let {
|
||||
private fun getUserConfig(): Config =
|
||||
userConfigFile.let {
|
||||
ConfigFactory.parseFile(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configs
|
||||
@@ -72,7 +71,8 @@ open class ConfigManager {
|
||||
val userConfig = getUserConfig()
|
||||
|
||||
val config =
|
||||
ConfigFactory.empty()
|
||||
ConfigFactory
|
||||
.empty()
|
||||
.withFallback(baseConfig)
|
||||
.withFallback(userConfig)
|
||||
.withFallback(compatConfig)
|
||||
@@ -153,11 +153,13 @@ open class ConfigManager {
|
||||
}
|
||||
|
||||
var newUserConfigDoc: ConfigDocument = resetUserConfig(false)
|
||||
userConfig.entrySet().filter {
|
||||
serverConfig.hasPath(
|
||||
it.key,
|
||||
)
|
||||
}.forEach { newUserConfigDoc = newUserConfigDoc.withValue(it.key, it.value) }
|
||||
userConfig
|
||||
.entrySet()
|
||||
.filter {
|
||||
serverConfig.hasPath(
|
||||
it.key,
|
||||
)
|
||||
}.forEach { newUserConfigDoc = newUserConfigDoc.withValue(it.key, it.value) }
|
||||
|
||||
userConfigFile.writeText(newUserConfigDoc.render())
|
||||
}
|
||||
|
||||
@@ -17,17 +17,25 @@ import kotlin.reflect.KProperty
|
||||
* Abstract config module.
|
||||
*/
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
abstract class ConfigModule(getConfig: () -> Config)
|
||||
abstract class ConfigModule(
|
||||
getConfig: () -> Config,
|
||||
)
|
||||
|
||||
/**
|
||||
* Abstract jvm-commandline-argument-overridable config module.
|
||||
*/
|
||||
abstract class SystemPropertyOverridableConfigModule(getConfig: () -> Config, moduleName: String) : ConfigModule(getConfig) {
|
||||
abstract class SystemPropertyOverridableConfigModule(
|
||||
getConfig: () -> Config,
|
||||
moduleName: String,
|
||||
) : ConfigModule(getConfig) {
|
||||
val overridableConfig = SystemPropertyOverrideDelegate(getConfig, moduleName)
|
||||
}
|
||||
|
||||
/** Defines a config property that is overridable with jvm `-D` commandline arguments prefixed with [CONFIG_PREFIX] */
|
||||
class SystemPropertyOverrideDelegate(val getConfig: () -> Config, val moduleName: String) {
|
||||
class SystemPropertyOverrideDelegate(
|
||||
val getConfig: () -> Config,
|
||||
val moduleName: String,
|
||||
) {
|
||||
inline operator fun <R, reified T> getValue(
|
||||
thisRef: R,
|
||||
property: KProperty<*>,
|
||||
|
||||
@@ -22,13 +22,12 @@ import org.slf4j.LoggerFactory
|
||||
private fun fileSizeValueOfOrDefault(
|
||||
fileSizeStr: String,
|
||||
default: String,
|
||||
): FileSize {
|
||||
return try {
|
||||
): FileSize =
|
||||
try {
|
||||
FileSize.valueOf(fileSizeStr)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
FileSize.valueOf(default)
|
||||
}
|
||||
}
|
||||
|
||||
private const val FILE_APPENDER_NAME = "SuwayomiDefaultAppender"
|
||||
|
||||
@@ -73,9 +72,8 @@ private fun createRollingFileAppender(
|
||||
return appender
|
||||
}
|
||||
|
||||
private fun getBaseLogger(): ch.qos.logback.classic.Logger {
|
||||
return (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger)
|
||||
}
|
||||
private fun getBaseLogger(): ch.qos.logback.classic.Logger =
|
||||
(KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger)
|
||||
|
||||
private fun getLogger(name: String): ch.qos.logback.classic.Logger {
|
||||
val context = LoggerFactory.getILoggerFactory() as LoggerContext
|
||||
|
||||
Reference in New Issue
Block a user