diff --git a/build.gradle.kts b/build.gradle.kts index 2769980..86fc34e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "cn.afternode" -version = "1.0-SNAPSHOT" +version = "1.0.1" repositories { mavenCentral() @@ -39,8 +39,10 @@ compose.desktop { nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb, TargetFormat.Exe) - packageName = "MoeTalkLocal" - packageVersion = "1.0.0" + packageName = "MoeTalkDesktop" + packageVersion = project.version as String + + modules("java.management") windows { console = true diff --git a/compose-desktop.pro b/compose-desktop.pro index 369768c..c9ce124 100644 --- a/compose-desktop.pro +++ b/compose-desktop.pro @@ -1,3 +1,6 @@ -dontwarn org.apache.** -dontwarn okhttp3.** --dontwarn io.netty.** \ No newline at end of file +-dontwarn io.netty.** + +-keep class org.apache.logging.** { *; } +-keep class org.slf4j.** { *; } diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index d00484f..b28e54d 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -18,12 +18,17 @@ import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.runtime.* import androidx.compose.ui.window.Window import androidx.compose.ui.window.application +import org.apache.logging.log4j.LogManager +import org.apache.logging.log4j.core.config.Configurator +import org.apache.logging.log4j.spi.LoggerContext import org.slf4j.LoggerFactory +import server.MoeTalk import server.Server import ui.ui import kotlin.system.exitProcess -private val logger = LoggerFactory.getLogger("Main") +val logCtx = Configurator.initialize("MoeTalkDesktop", MoeTalk::class.java.classLoader, "log4j2.xml") +private val logger by lazy { logCtx.getLogger("Main") } @Composable @Preview @@ -32,6 +37,7 @@ fun App() { } fun main() = application { + logger.info("Starting application") Window(onCloseRequest = ::onExit, title = "MoeTalk Desktop") { App() } diff --git a/src/main/kotlin/server/MoeTalk.kt b/src/main/kotlin/server/MoeTalk.kt index 321612d..edb85df 100644 --- a/src/main/kotlin/server/MoeTalk.kt +++ b/src/main/kotlin/server/MoeTalk.kt @@ -16,6 +16,7 @@ package server +import logCtx import okhttp3.OkHttpClient import okhttp3.Request import org.slf4j.LoggerFactory @@ -32,7 +33,7 @@ import kotlin.io.path.createDirectories import kotlin.io.path.exists object MoeTalk { - val logger = LoggerFactory.getLogger("Installer") + val logger = logCtx.getLogger("Installer") val installDir by lazy { File("moe-talk") } var proxyHost: String? = null diff --git a/src/main/kotlin/server/Server.kt b/src/main/kotlin/server/Server.kt index 95b3a36..f74eb4c 100644 --- a/src/main/kotlin/server/Server.kt +++ b/src/main/kotlin/server/Server.kt @@ -21,10 +21,11 @@ import io.ktor.server.engine.* import io.ktor.server.netty.* import io.ktor.server.plugins.callloging.* import io.ktor.server.routing.* +import logCtx import org.slf4j.LoggerFactory object Server { - val logger = LoggerFactory.getLogger("Server") + val logger = logCtx.getLogger("Server") var port: Int = 8080 @@ -45,7 +46,9 @@ object Server { try { logger.info("Starting server on $port") engine = embeddedServer(Netty, port = port) { - install(CallLogging) + install(CallLogging) { + disableDefaultColors() + } routing { routeMoeTalk()