mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Setup redirects to log to logger instead of just SDTOUT
This commit is contained in:
@@ -63,6 +63,9 @@ dependencies {
|
|||||||
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
|
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
|
val slf4jVersion = "1.7.31"
|
||||||
|
implementation("org.slf4j:slf4j-api:$slf4jVersion")
|
||||||
|
implementation("org.slf4j:jul-to-slf4j:$slf4jVersion")
|
||||||
val log4jVersion = "2.14.1"
|
val log4jVersion = "2.14.1"
|
||||||
implementation("org.apache.logging.log4j:log4j-api:$log4jVersion")
|
implementation("org.apache.logging.log4j:log4j-api:$log4jVersion")
|
||||||
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
|
implementation("org.apache.logging.log4j:log4j-core:$log4jVersion")
|
||||||
|
|||||||
@@ -6,13 +6,18 @@
|
|||||||
|
|
||||||
package ca.gosyer.core.logging
|
package ca.gosyer.core.logging
|
||||||
|
|
||||||
|
import ca.gosyer.BuildConfig
|
||||||
|
import com.github.weisj.darklaf.LafManager
|
||||||
|
import mu.KotlinLogging
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import org.apache.logging.log4j.core.LoggerContext
|
import org.apache.logging.log4j.core.LoggerContext
|
||||||
import org.apache.logging.log4j.core.appender.ConsoleAppender
|
import org.apache.logging.log4j.core.appender.ConsoleAppender
|
||||||
import org.apache.logging.log4j.core.config.builder.api.ComponentBuilder
|
import org.apache.logging.log4j.core.config.builder.api.ComponentBuilder
|
||||||
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory
|
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory
|
||||||
|
import org.slf4j.bridge.SLF4JBridgeHandler
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.logging.LogManager as JLogManager
|
||||||
|
|
||||||
const val consolePattern =
|
const val consolePattern =
|
||||||
"%highlight{%d{" + '$' + "{LOG_DATEFORMAT_PATTERN:-HH:mm:ss.SSS}} [%t] " + '$' + "{LOG_LEVEL_PATTERN:-%p}/%c{1}: %m%n" + '$' + "{LOG_EXCEPTION_CONVERSION_WORD:-%xEx}}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=black, TRACE=black}"
|
"%highlight{%d{" + '$' + "{LOG_DATEFORMAT_PATTERN:-HH:mm:ss.SSS}} [%t] " + '$' + "{LOG_LEVEL_PATTERN:-%p}/%c{1}: %m%n" + '$' + "{LOG_EXCEPTION_CONVERSION_WORD:-%xEx}}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=black, TRACE=black}"
|
||||||
@@ -73,4 +78,21 @@ fun initializeLogger(loggingLocation: File) {
|
|||||||
}
|
}
|
||||||
ctx.configuration = builder.build()
|
ctx.configuration = builder.build()
|
||||||
ctx.updateLoggers()
|
ctx.updateLoggers()
|
||||||
|
|
||||||
|
// Initialize Darklaf logger
|
||||||
|
LafManager.setLogLevel(
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
java.util.logging.Level.FINE
|
||||||
|
} else {
|
||||||
|
java.util.logging.Level.WARNING
|
||||||
|
}
|
||||||
|
)
|
||||||
|
JLogManager.getLogManager().getLogger("com.github.weisj.darklaf").apply {
|
||||||
|
handlers.forEach { removeHandler(it) }
|
||||||
|
addHandler(SLF4JBridgeHandler())
|
||||||
|
}
|
||||||
|
val logger = KotlinLogging.logger("UncaughtException")
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler { t, e ->
|
||||||
|
logger.error(e) { "Uncaught exception in thread [${t.name}@${t.id}]" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import toothpick.configuration.Configuration
|
|||||||
import toothpick.ktp.KTP
|
import toothpick.ktp.KTP
|
||||||
import toothpick.ktp.extension.getInstance
|
import toothpick.ktp.extension.getInstance
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.logging.Level
|
|
||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
fun main() {
|
fun main() {
|
||||||
@@ -78,13 +77,6 @@ fun main() {
|
|||||||
ThemeMode.Light -> IntelliJTheme()
|
ThemeMode.Light -> IntelliJTheme()
|
||||||
ThemeMode.Dark -> DarculaTheme()
|
ThemeMode.Dark -> DarculaTheme()
|
||||||
}
|
}
|
||||||
LafManager.setLogLevel(
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Level.FINE
|
|
||||||
} else {
|
|
||||||
Level.WARNING
|
|
||||||
}
|
|
||||||
)
|
|
||||||
withUIContext {
|
withUIContext {
|
||||||
LafManager.install(theme)
|
LafManager.install(theme)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user