diff --git a/src/main/kotlin/com/viaversion/aas/AspirinServer.kt b/src/main/kotlin/com/viaversion/aas/AspirinServer.kt index c5f497e..98bdff8 100644 --- a/src/main/kotlin/com/viaversion/aas/AspirinServer.kt +++ b/src/main/kotlin/com/viaversion/aas/AspirinServer.kt @@ -127,9 +127,13 @@ object AspirinServer { ktorServer = embeddedServer(Netty, commandLineEnvironment(args)) {}.start(false) - viaaasLogger.info("Using compression: ${Natives.compress.loadedVariant}, crypto: ${Natives.cipher.loadedVariant}") + viaaasLogger.info( + "Using compression: {}, crypto: {}", + Natives.compress.loadedVariant, + Natives.cipher.loadedVariant + ) chFutures.forEach { - viaaasLogger.info("Binded minecraft into " + it.sync().channel().localAddress()) + viaaasLogger.info("Binded minecraft into {}", it.sync().channel().localAddress()) } viaaasLogger.info( "Application started in " + ManagementFactory.getRuntimeMXBean().uptime diff --git a/src/main/kotlin/com/viaversion/aas/VIAaaS.kt b/src/main/kotlin/com/viaversion/aas/VIAaaS.kt index 5914455..385548b 100644 --- a/src/main/kotlin/com/viaversion/aas/VIAaaS.kt +++ b/src/main/kotlin/com/viaversion/aas/VIAaaS.kt @@ -21,7 +21,7 @@ fun main(args: Array) { try { setupSystem() printSplash() - CoroutineScope(Job()).launch { viaaasLogger.info(AspirinServer.updaterCheckMessage()) } + CoroutineScope(Job()).launch { viaaasLogger.info("{}", AspirinServer.updaterCheckMessage()) } AspirinServer.generateCert() initVia() AspirinServer.listenPorts(args) diff --git a/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt b/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt index 11ba8ea..e3c9af1 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/MinecraftHandler.kt @@ -64,7 +64,7 @@ class MinecraftHandler( if (cause is CancelCodecException) return if (cause is ClosedChannelException) return val exceptionId = ThreadLocalRandom.current().nextInt().toUInt().toString(36) - mcLogger.debug("Exception $exceptionId: ", cause) + mcLogger.debug("Exception {}: ", exceptionId, cause) disconnect("$cause #$exceptionId") } diff --git a/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt b/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt index 1d314b3..1ab48e4 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/autoprotocol/ProtocolDetectionState.kt @@ -23,7 +23,7 @@ class ProtocolDetectionState(val future: CompletableFuture) : C val ver = JsonParser.parseString(packet.msg).asJsonObject .getAsJsonObject("version")["protocol"].asInt.parseProtocol() future.complete(ver) - mcLogger.info("A.D.: ${handler.endRemoteAddress} $ver") + mcLogger.info("A.D.: {} {}", handler.endRemoteAddress, ver) } override fun disconnect(handler: MinecraftHandler, msg: String) { diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/ConnectionState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/ConnectionState.kt index 23b28cf..da9e25c 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/ConnectionState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/ConnectionState.kt @@ -17,12 +17,11 @@ interface ConnectionState { private fun logDisconnect(handler: MinecraftHandler, msg: String?) { val reason = msg ?: if (handler.backEnd && kickedByServer) "kicked" else "-" - val formatted = "- ${handler.endRemoteAddress}: $reason" if (logDcInfo && !handler.loggedDc) { handler.loggedDc = true - mcLogger.info(formatted) + mcLogger.info("- {}: {}", handler.endRemoteAddress, reason) } else { - mcLogger.debug(formatted) + mcLogger.debug("- {}: {}", handler.endRemoteAddress, reason) } } diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt index cc7723b..848ce6d 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt @@ -99,8 +99,8 @@ class HandshakeState : ConnectionState { val playerAddr = handler.data.frontHandler.endRemoteAddress mcLogger.debug( - "HS: $playerAddr ${handler.data.state.state.name[0]} " + - "$virtualHostNoExtra $virtualPort v${handler.data.frontVer}" + "HS: {} {} {} {} v{}", + playerAddr, handler.data.state.state.name, virtualHostNoExtra, virtualPort, handler.data.frontVer ) if (!usedDefault && !hadHostname && VIAaaSConfig.requireHostName && !addressFromWeb diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt index 37f5eb5..a546ee7 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/LoginState.kt @@ -178,7 +178,10 @@ class LoginState : ConnectionState { val backKey = generate128Bits() val backHash = generateServerHash(backServerId, backKey, backPublicKey) - mcLogger.info("Session req: ${handler.data.frontHandler.endRemoteAddress} ($playerId $frontName) $backName") + mcLogger.info( + "Session req: {} ({} {}) {}", + handler.data.frontHandler.endRemoteAddress, playerId, frontName, backName + ) val pluginReauthed = reauthMessage(handler, backName!!, backHash).await() if (!pluginReauthed) { AspirinServer.viaWebServer.requestSessionJoin( @@ -258,7 +261,7 @@ class LoginState : ConnectionState { handler.coroutineScope.launch(Dispatchers.IO) { try { if (backAddress == null) { - mcLogger.info("Requesting address info from web for $frontName") + mcLogger.info("Requesting address info from web for {}", frontName) val info = AspirinServer.viaWebServer.requestAddressInfo(frontName).await() backAddress = info.backHostAndPort handler.data.backServerVer = info.backVersion @@ -273,7 +276,7 @@ class LoginState : ConnectionState { else -> {} } val id = callbackPlayerId.await() - mcLogger.info("Login: ${handler.endRemoteAddress} $frontName $id") + mcLogger.info("Login: {} {} {}", handler.endRemoteAddress, frontName, id) } connectBack( handler, diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt b/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt index 8aed6a2..fab755a 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/Util.kt @@ -51,7 +51,11 @@ private suspend fun createBackChannel( .channel() (channel.pipeline()["proxy"] as? ProxyHandler)?.connectFuture()?.suspendAwait() - mcLogger.info("+ ${state.name[0]} ${handler.endRemoteAddress} -> $socketAddr") + if (state == State.LOGIN) { + mcLogger.info("+ L {} -> {}", handler.endRemoteAddress, socketAddr) + } else { + mcLogger.debug("+ {} {} -> {}", state.name[0], handler.endRemoteAddress, socketAddr) + } handler.data.backChannel = channel as SocketChannel autoDetectVersion(handler, socketAddr) @@ -77,7 +81,7 @@ private suspend fun autoDetectVersion(handler: MinecraftHandler, socketAddr: Ine ProtocolDetector.detectVersion(socketAddr).await() } } catch (e: Exception) { - mcLogger.warn("Failed to detect version of $socketAddr: $e") + mcLogger.warn("Failed to detect version of {}: {}", socketAddr, e.toString()) mcLogger.debug("Stacktrace: ", e) } diff --git a/src/main/kotlin/com/viaversion/aas/web/WebLogin.kt b/src/main/kotlin/com/viaversion/aas/web/WebLogin.kt index 9f6aa06..bc290f2 100644 --- a/src/main/kotlin/com/viaversion/aas/web/WebLogin.kt +++ b/src/main/kotlin/com/viaversion/aas/web/WebLogin.kt @@ -81,7 +81,7 @@ class WebLogin : WebState { val token = webClient.server.generateToken(uuid, username) webClient.ws.sendSerialized(loginSuccessJson(username, uuid, token)) - webLogger.info("Token gen: ${webClient.id}: offline $username $uuid") + webLogger.info("Token gen: {}: offline {} {}", webClient.id, username, uuid) } private suspend fun handleMcIdLogin(webClient: WebClient, obj: JsonObject) { @@ -102,10 +102,10 @@ class WebLogin : WebState { val token = webClient.server.generateToken(uuid, mcIdUser) webClient.ws.sendSerialized(loginSuccessJson(mcIdUser, uuid, token)) - webLogger.info("Token gen: ${webClient.id}: $mcIdUser $uuid") + webLogger.info("Token gen: {}: {} {}", webClient.id, mcIdUser, uuid) } else { webClient.ws.sendSerialized(loginNotSuccess()) - webLogger.info("Token gen fail: ${webClient.id}: $username") + webLogger.info("Token gen fail: {}: {}", webClient.id, username) } } @@ -120,17 +120,17 @@ class WebLogin : WebState { response.addProperty("success", true) response.addProperty("user", user.id.toString()) response.addProperty("username", user.name) - webLogger.info("Listen: ${webClient.id}: $user") + webLogger.info("Listen: {}: {}", webClient.id, user) } else { response.addProperty("success", false) - webLogger.info("Listen fail: ${webClient.id}") + webLogger.info("Listen fail: {}", webClient.id) } webClient.ws.sendSerialized(response) } private suspend fun handleUnlisten(webClient: WebClient, obj: JsonObject) { val uuid = UUID.fromString(obj["uuid"].asString) - webLogger.info("Unlisten: ${webClient.id}: $uuid") + webLogger.info("Unlisten: {}: {}", webClient.id, uuid) val response = JsonObject().also { it.addProperty("action", "unlisten_login_requests_result") it.addProperty("uuid", uuid.toString()) diff --git a/src/main/kotlin/com/viaversion/aas/web/WebServer.kt b/src/main/kotlin/com/viaversion/aas/web/WebServer.kt index 23e0bdd..95dd9e0 100644 --- a/src/main/kotlin/com/viaversion/aas/web/WebServer.kt +++ b/src/main/kotlin/com/viaversion/aas/web/WebServer.kt @@ -119,7 +119,7 @@ class WebServer { try { onlineId = usernameToIdCache[frontName].await() } catch (e: java.lang.Exception) { - webLogger.debug("Couldn't get online uuid for $frontName", e) + webLogger.debug("Couldn't get online uuid for {}", frontName, e) } val offlineId = generateOfflinePlayerUuid(frontName) @@ -233,7 +233,7 @@ class WebServer { suspend fun connected(ws: WebSocketServerSession) { val loginState = WebLogin() val client = WebClient(this, ws, loginState) - webLogger.info("+ WS: ${client.id}") + webLogger.info("+ WS: {}", client.id) clients[ws] = client loginState.start(client) } @@ -248,14 +248,14 @@ class WebServer { suspend fun disconnected(ws: WebSocketServerSession) { val client = clients[ws]!! - webLogger.info("- WS: ${client.id}") + webLogger.info("- WS: {}", client.id) client.state.disconnected(client) clients.remove(ws) } suspend fun onException(ws: WebSocketServerSession, exception: Throwable) { val client = clients[ws]!! - webLogger.info("WS Error: ${client.id} $exception") + webLogger.info("WS Error: {} {}", client.id, exception.toString()) webLogger.debug("Ws exception: ", exception) client.state.onException(client, exception) }