From a32d41edd27b984de947009b939b1e12315a0ea6 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 3 Mar 2021 19:12:41 +0000 Subject: Better logging of cases where the stream was terminated --- server/src/net/usebox/gemini/server/Server.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'server/src') diff --git a/server/src/net/usebox/gemini/server/Server.scala b/server/src/net/usebox/gemini/server/Server.scala index 76c64c4..a250158 100644 --- a/server/src/net/usebox/gemini/server/Server.scala +++ b/server/src/net/usebox/gemini/server/Server.scala @@ -227,13 +227,16 @@ case class Server(conf: ServiceConf) { closing = TLSClosing.ignoreCancel ) .runForeach { connection => - logger.debug(s"new connection ${connection.remoteAddress}") + val remoteHost = connection.remoteAddress.getHostString() + logger.debug(s"new connection $remoteHost") val handler = Flow[ByteString] .watchTermination() { (_, f) => f.onComplete { _.toEither.swap.map(error => - logger.warn(s"stream terminated: ${error.getMessage()}") + logger.warn( + s"$remoteHost - stream terminated: ${error.getMessage()}" + ) ) } } @@ -263,8 +266,7 @@ case class Server(conf: ServiceConf) { .take(1) .wireTap(resp => logger.info( - s"""${connection.remoteAddress - .getHostString()} "${resp.req}" ${resp.status} ${resp.bodySize}""" + s"""$remoteHost "${resp.req}" ${resp.status} ${resp.bodySize}""" ) ) .flatMapConcat(_.toSource) -- cgit v1.2.3