mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-01-11 16:29:08 +01:00
better logging
This commit is contained in:
parent
ec877f632f
commit
95c437efd5
@ -71,7 +71,7 @@ private fun dex2jar(dexFile: String, jarFile: String, fileNameWithoutType: Strin
|
||||
}
|
||||
|
||||
fun installAPK(apkName: String): Int {
|
||||
logger.info("Installing $apkName")
|
||||
logger.debug("Installing $apkName")
|
||||
val extensionRecord = getExtensionList(true).first { it.apkName == apkName }
|
||||
val fileNameWithoutType = apkName.substringBefore(".apk")
|
||||
val dirPathWithoutType = "${applicationDirs.extensionsRoot}/$fileNameWithoutType"
|
||||
@ -91,7 +91,7 @@ fun installAPK(apkName: String): Int {
|
||||
downloadAPKFile(apkToDownload, apkFilePath)
|
||||
|
||||
val className: String = APKExtractor.extract_dex_and_read_className(apkFilePath, dexFilePath)
|
||||
logger.info(className)
|
||||
logger.debug(className)
|
||||
// dex -> jar
|
||||
dex2jar(dexFilePath, jarFilePath, fileNameWithoutType)
|
||||
|
||||
@ -119,7 +119,7 @@ fun installAPK(apkName: String): Int {
|
||||
it[extension] = extensionId
|
||||
}
|
||||
}
|
||||
logger.info("Installed source ${httpSource.name} with id {httpSource.id}")
|
||||
logger.debug("Installed source ${httpSource.name} with id {httpSource.id}")
|
||||
}
|
||||
} else { // multi source
|
||||
val sourceFactory = instance as SourceFactory
|
||||
@ -136,7 +136,7 @@ fun installAPK(apkName: String): Int {
|
||||
it[positionInFactorySource] = index
|
||||
}
|
||||
}
|
||||
logger.info("Installed source ${httpSource.name} with id:${httpSource.id}")
|
||||
logger.debug("Installed source ${httpSource.name} with id:${httpSource.id}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ private fun downloadAPKFile(url: String, apkPath: String) {
|
||||
}
|
||||
|
||||
fun removeExtension(apkName: String) {
|
||||
logger.info("Uninstalling $apkName")
|
||||
logger.debug("Uninstalling $apkName")
|
||||
|
||||
val extensionRecord = getExtensionList(true).first { it.apkName == apkName }
|
||||
val fileNameWithoutType = apkName.substringBefore(".apk")
|
||||
|
@ -34,7 +34,7 @@ private fun extensionDatabaseIsEmtpy(): Boolean {
|
||||
fun getExtensionList(offline: Boolean = false): List<ExtensionDataClass> {
|
||||
// update if 60 seconds has passed or requested offline and database is empty
|
||||
if (Data.lastExtensionCheck + 60 * 1000 < System.currentTimeMillis() || (offline && extensionDatabaseIsEmtpy())) {
|
||||
logger.info("Getting extensions list from the internet")
|
||||
logger.debug("Getting extensions list from the internet")
|
||||
Data.lastExtensionCheck = System.currentTimeMillis()
|
||||
var foundExtensions: List<Extension.Available>
|
||||
runBlocking {
|
||||
@ -72,7 +72,7 @@ fun getExtensionList(offline: Boolean = false): List<ExtensionDataClass> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.info("used cached extension list")
|
||||
logger.debug("used cached extension list")
|
||||
}
|
||||
|
||||
return transaction {
|
||||
|
@ -35,7 +35,7 @@ fun getHttpSource(sourceId: Long): HttpSource {
|
||||
|
||||
val cachedResult: Pair<Long, HttpSource>? = sourceCache.firstOrNull { it.first == sourceId }
|
||||
if (cachedResult != null) {
|
||||
logger.info("used cached HttpSource: ${cachedResult.second.name}")
|
||||
logger.debug("used cached HttpSource: ${cachedResult.second.name}")
|
||||
return cachedResult.second
|
||||
}
|
||||
|
||||
@ -52,10 +52,10 @@ fun getHttpSource(sourceId: Long): HttpSource {
|
||||
val instance =
|
||||
if (cachedExtensionPair != null) {
|
||||
usedCached = true
|
||||
logger.info("Used cached Extension")
|
||||
logger.debug("Used cached Extension")
|
||||
cachedExtensionPair.second
|
||||
} else {
|
||||
logger.info("No Extension cache")
|
||||
logger.debug("No Extension cache")
|
||||
val child = URLClassLoader(arrayOf<URL>(URL("file:$jarPath")), this::class.java.classLoader)
|
||||
val classToLoad = Class.forName(className, true, child)
|
||||
classToLoad.newInstance()
|
||||
|
@ -40,6 +40,12 @@ fun applicationSetup() {
|
||||
ServerConfig.register(GlobalConfigManager.config)
|
||||
)
|
||||
|
||||
// set application wide logging level
|
||||
if (serverConfig.debugLogsEnabled) {
|
||||
// (mu.KotlinLogging.logger("ir.armor.tachidesk").underlyingLogger as ch.qos.logback.classic.Logger).level = Level.DEBUG
|
||||
(mu.KotlinLogging.logger(org.slf4j.Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger).level = Level.DEBUG
|
||||
}
|
||||
|
||||
// make dirs we need
|
||||
listOf(
|
||||
applicationDirs.dataRoot,
|
||||
@ -83,11 +89,8 @@ fun applicationSetup() {
|
||||
// start app
|
||||
androidCompat.startApp(App())
|
||||
|
||||
// set application wide logging level
|
||||
if (!serverConfig.debugLogsEnabled)
|
||||
(mu.KotlinLogging.logger("ir.armor.tachidesk").underlyingLogger as ch.qos.logback.classic.Logger).level = Level.INFO
|
||||
|
||||
// Disable jetty's logging
|
||||
System.setProperty("org.eclipse.jetty.util.log.announce", "false")
|
||||
System.setProperty("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.StdErrLog")
|
||||
System.setProperty("org.eclipse.jetty.LEVEL", "OFF")
|
||||
|
||||
|
@ -13,6 +13,7 @@ import dorkbox.systemTray.SystemTray.TrayType
|
||||
import dorkbox.util.CacheUtil
|
||||
import dorkbox.util.Desktop
|
||||
import ir.armor.tachidesk.Main
|
||||
import ir.armor.tachidesk.server.serverConfig
|
||||
import java.awt.event.ActionListener
|
||||
import java.io.IOException
|
||||
|
||||
@ -27,7 +28,7 @@ fun openInBrowser() {
|
||||
fun systemTray(): SystemTray? {
|
||||
try {
|
||||
// ref: https://github.com/dorkbox/SystemTray/blob/master/test/dorkbox/TestTray.java
|
||||
SystemTray.DEBUG = false
|
||||
SystemTray.DEBUG = serverConfig.debugLogsEnabled
|
||||
if (System.getProperty("os.name").startsWith("Windows"))
|
||||
SystemTray.FORCE_TRAY_TYPE = TrayType.Swing
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="Exposed" level="OFF"/>
|
||||
<logger name="Exposed" level="ERROR"/>
|
||||
|
||||
<root level="debug">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
Loading…
x
Reference in New Issue
Block a user