From cf58756faa1ee9e0ab2b62ccc82408bf8d8de070 Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Mon, 22 Jun 2020 12:08:46 -0500 Subject: [PATCH] Fine-tune logging statements --- src/main/kotlin/mdnet/base/MangaDexClient.kt | 19 +++++++++++-------- src/main/kotlin/mdnet/base/dao/metadata.kt | 1 + .../mdnet/base/netty/ApplicationNetty.kt | 5 +++-- .../mdnet/base/settings/ClientSettings.kt | 1 + 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/mdnet/base/MangaDexClient.kt b/src/main/kotlin/mdnet/base/MangaDexClient.kt index c2717da..3b2da5b 100644 --- a/src/main/kotlin/mdnet/base/MangaDexClient.kt +++ b/src/main/kotlin/mdnet/base/MangaDexClient.kt @@ -82,7 +82,7 @@ class MangaDexClient(private val clientSettings: ClientSettings) { LOGGER.warn("Cache version may be outdated - remove if necessary") dieWithError(e) } catch (e: IOException) { - LOGGER.warn("Cache version may be corrupt - remove if necessary") + LOGGER.warn("Cache may be corrupt - remove if necessary") dieWithError(e) } } @@ -204,15 +204,15 @@ class MangaDexClient(private val clientSettings: ClientSettings) { val state = this.state as Running val newSettings = serverHandler.pingControl(state.settings) - if (LOGGER.isInfoEnabled) { - LOGGER.info("Server settings received: {}", newSettings) - } if (newSettings != null) { + if (LOGGER.isInfoEnabled) { + LOGGER.info("Server settings received: $newSettings") + } + if (newSettings.latestBuild > Constants.CLIENT_BUILD) { if (LOGGER.isWarnEnabled) { LOGGER.warn( - "Outdated build detected! Latest: {}, Current: {}", newSettings.latestBuild, - Constants.CLIENT_BUILD + "Outdated build detected! Latest: ${newSettings.latestBuild}, Current: ${Constants.CLIENT_BUILD}" ) } } @@ -225,6 +225,10 @@ class MangaDexClient(private val clientSettings: ClientSettings) { loginAndStartServer() } } + } else { + if (LOGGER.isInfoEnabled) { + LOGGER.info("Server ping failed - ignoring") + } } } @@ -238,8 +242,7 @@ class MangaDexClient(private val clientSettings: ClientSettings) { if (serverSettings.latestBuild > Constants.CLIENT_BUILD) { if (LOGGER.isWarnEnabled) { LOGGER.warn( - "Outdated build detected! Latest: {}, Current: {}", serverSettings.latestBuild, - Constants.CLIENT_BUILD + "Outdated build detected! Latest: ${serverSettings.latestBuild}, Current: ${Constants.CLIENT_BUILD}" ) } } diff --git a/src/main/kotlin/mdnet/base/dao/metadata.kt b/src/main/kotlin/mdnet/base/dao/metadata.kt index c71ce5e..80df223 100644 --- a/src/main/kotlin/mdnet/base/dao/metadata.kt +++ b/src/main/kotlin/mdnet/base/dao/metadata.kt @@ -24,6 +24,7 @@ import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.dao.id.IdTable object ImageData : IdTable() { + // md5 hex strings are 32 characters long override val id = varchar("id", 32).entityId() override val primaryKey = PrimaryKey(id) diff --git a/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt b/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt index 39f6b0e..52c1f78 100644 --- a/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt +++ b/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt @@ -49,6 +49,7 @@ import java.io.ByteArrayInputStream import java.io.IOException import java.io.InputStream import java.net.InetSocketAddress +import java.net.SocketException import java.security.PrivateKey import java.security.cert.CertificateFactory import java.security.cert.X509Certificate @@ -107,12 +108,12 @@ class Netty(private val tls: TlsCert, private val clientSettings: ClientSettings if (LOGGER.isTraceEnabled) { LOGGER.trace("Ignored invalid SSL connection") } - } else if (cause is IOException) { + } else if (cause is IOException || cause is SocketException) { if (LOGGER.isInfoEnabled) { LOGGER.info("User (downloader) abruptly closed the connection") } if (LOGGER.isTraceEnabled) { - LOGGER.trace("IOException in pipeline", cause) + LOGGER.trace("Exception in pipeline", cause) } } else { ctx.fireExceptionCaught(cause) diff --git a/src/main/kotlin/mdnet/base/settings/ClientSettings.kt b/src/main/kotlin/mdnet/base/settings/ClientSettings.kt index 33368a7..771dc6c 100644 --- a/src/main/kotlin/mdnet/base/settings/ClientSettings.kt +++ b/src/main/kotlin/mdnet/base/settings/ClientSettings.kt @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategy import com.fasterxml.jackson.databind.annotation.JsonNaming import dev.afanasev.sekret.Secret +// client settings are verified correct in Main.kt @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class) data class ClientSettings( val maxCacheSizeInMebibytes: Long = 20480,