Add Markers logs
[dcaegen2/collectors/hv-ves.git] / sources / hv-collector-core / src / main / kotlin / org / onap / dcae / collectors / veshv / impl / socket / NettyTcpServer.kt
index 2d29fe9..3fa05c4 100644 (file)
@@ -27,6 +27,7 @@ import org.onap.dcae.collectors.veshv.model.ClientContext
 import org.onap.dcae.collectors.veshv.model.ClientContextLogging.info
 import org.onap.dcae.collectors.veshv.model.ClientContextLogging.debug
 import org.onap.dcae.collectors.veshv.model.ClientContextLogging.withWarn
+import org.onap.dcae.collectors.veshv.utils.logging.Marker
 import org.onap.dcae.collectors.veshv.model.ServerConfiguration
 import org.onap.dcae.collectors.veshv.ssl.boundary.ServerSslContextFactory
 import org.onap.dcae.collectors.veshv.utils.NettyServerHandle
@@ -74,13 +75,14 @@ internal class NettyTcpServer(private val serverConfig: ServerConfiguration,
             clientContext.clientAddress = it.address()
         }
 
+        logger.debug(clientContext::asMap, Marker.ENTRY) { "Client connection request received" }
         return collectorProvider(clientContext).fold(
                 {
                     logger.warn(clientContext::asMap) { "Collector not ready. Closing connection..." }
                     Mono.empty()
                 },
                 {
-                    logger.info { "Handling new connection" }
+                    logger.info(clientContext::asMap) { "Handling new connection" }
                     nettyInbound.withConnection { conn ->
                         conn.configureIdleTimeout(clientContext, serverConfig.idleTimeout)
                                 .logConnectionClosed(clientContext)
@@ -106,6 +108,7 @@ internal class NettyTcpServer(private val serverConfig: ServerConfiguration,
 
     private fun Connection.disconnectClient(ctx: ClientContext) {
         channel().close().addListener {
+            logger.debug(ctx::asMap, Marker.EXIT) { "Closing client channel." }
             if (it.isSuccess)
                 logger.debug(ctx) { "Channel closed successfully." }
             else
@@ -115,7 +118,8 @@ internal class NettyTcpServer(private val serverConfig: ServerConfiguration,
 
     private fun Connection.logConnectionClosed(ctx: ClientContext): Connection {
         onTerminate().subscribe {
-            logger.info(ctx) { "Connection has been closed" }
+            // TODO: this code is never executed (at least with ssl-enabled, did not checked with ssl-disabled)
+            logger.info(ctx::asMap, Marker.EXIT) { "Connection has been closed" }
         }
         return this
     }