Fine-tune logging statements

This commit is contained in:
carbotaniuman 2020-06-22 12:08:46 -05:00
parent 18f05f4ccd
commit cf58756faa
4 changed files with 16 additions and 10 deletions

View file

@ -82,7 +82,7 @@ class MangaDexClient(private val clientSettings: ClientSettings) {
LOGGER.warn("Cache version may be outdated - remove if necessary") LOGGER.warn("Cache version may be outdated - remove if necessary")
dieWithError(e) dieWithError(e)
} catch (e: IOException) { } catch (e: IOException) {
LOGGER.warn("Cache version may be corrupt - remove if necessary") LOGGER.warn("Cache may be corrupt - remove if necessary")
dieWithError(e) dieWithError(e)
} }
} }
@ -204,15 +204,15 @@ class MangaDexClient(private val clientSettings: ClientSettings) {
val state = this.state as Running val state = this.state as Running
val newSettings = serverHandler.pingControl(state.settings) val newSettings = serverHandler.pingControl(state.settings)
if (LOGGER.isInfoEnabled) {
LOGGER.info("Server settings received: {}", newSettings)
}
if (newSettings != null) { if (newSettings != null) {
if (LOGGER.isInfoEnabled) {
LOGGER.info("Server settings received: $newSettings")
}
if (newSettings.latestBuild > Constants.CLIENT_BUILD) { if (newSettings.latestBuild > Constants.CLIENT_BUILD) {
if (LOGGER.isWarnEnabled) { if (LOGGER.isWarnEnabled) {
LOGGER.warn( LOGGER.warn(
"Outdated build detected! Latest: {}, Current: {}", newSettings.latestBuild, "Outdated build detected! Latest: ${newSettings.latestBuild}, Current: ${Constants.CLIENT_BUILD}"
Constants.CLIENT_BUILD
) )
} }
} }
@ -225,6 +225,10 @@ class MangaDexClient(private val clientSettings: ClientSettings) {
loginAndStartServer() 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 (serverSettings.latestBuild > Constants.CLIENT_BUILD) {
if (LOGGER.isWarnEnabled) { if (LOGGER.isWarnEnabled) {
LOGGER.warn( LOGGER.warn(
"Outdated build detected! Latest: {}, Current: {}", serverSettings.latestBuild, "Outdated build detected! Latest: ${serverSettings.latestBuild}, Current: ${Constants.CLIENT_BUILD}"
Constants.CLIENT_BUILD
) )
} }
} }

View file

@ -24,6 +24,7 @@ import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.dao.id.IdTable import org.jetbrains.exposed.dao.id.IdTable
object ImageData : IdTable<String>() { object ImageData : IdTable<String>() {
// md5 hex strings are 32 characters long
override val id = varchar("id", 32).entityId() override val id = varchar("id", 32).entityId()
override val primaryKey = PrimaryKey(id) override val primaryKey = PrimaryKey(id)

View file

@ -49,6 +49,7 @@ import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.net.InetSocketAddress import java.net.InetSocketAddress
import java.net.SocketException
import java.security.PrivateKey import java.security.PrivateKey
import java.security.cert.CertificateFactory import java.security.cert.CertificateFactory
import java.security.cert.X509Certificate import java.security.cert.X509Certificate
@ -107,12 +108,12 @@ class Netty(private val tls: TlsCert, private val clientSettings: ClientSettings
if (LOGGER.isTraceEnabled) { if (LOGGER.isTraceEnabled) {
LOGGER.trace("Ignored invalid SSL connection") LOGGER.trace("Ignored invalid SSL connection")
} }
} else if (cause is IOException) { } else if (cause is IOException || cause is SocketException) {
if (LOGGER.isInfoEnabled) { if (LOGGER.isInfoEnabled) {
LOGGER.info("User (downloader) abruptly closed the connection") LOGGER.info("User (downloader) abruptly closed the connection")
} }
if (LOGGER.isTraceEnabled) { if (LOGGER.isTraceEnabled) {
LOGGER.trace("IOException in pipeline", cause) LOGGER.trace("Exception in pipeline", cause)
} }
} else { } else {
ctx.fireExceptionCaught(cause) ctx.fireExceptionCaught(cause)

View file

@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategy
import com.fasterxml.jackson.databind.annotation.JsonNaming import com.fasterxml.jackson.databind.annotation.JsonNaming
import dev.afanasev.sekret.Secret import dev.afanasev.sekret.Secret
// client settings are verified correct in Main.kt
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class) @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
data class ClientSettings( data class ClientSettings(
val maxCacheSizeInMebibytes: Long = 20480, val maxCacheSizeInMebibytes: Long = 20480,