Skip to content

Commit

Permalink
Added log information hexagontk#272
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpascal1 committed Mar 20, 2020
1 parent 9e26bc9 commit f9784d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 0 additions & 4 deletions hexagon_web/src/main/kotlin/com/hexagonkt/web/Web.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.hexagonkt.web

import com.hexagonkt.helpers.logger
import java.util.Locale.forLanguageTag as localeFor

import com.hexagonkt.http.server.Call
Expand All @@ -15,8 +14,6 @@ fun Call.templateType(template: String) {
if (response.contentType == null) {
val mimeType = SerializationManager.contentTypeOf(template.substringAfterLast('.'))
response.contentType = "$mimeType; charset=${defaultCharset().name()}"
logger.trace { response }
logger.trace { response.contentType }
}
}

Expand All @@ -25,7 +22,6 @@ fun Call.fullContext(): Map<String, *> {
"path" to request.path.removeSuffix("/"), // Do not allow trailing slash
"lang" to obtainLocale().language
)
logger.trace { extraParameters }

return settings + session.attributes + extraParameters
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hexagonkt.http.client.ahc

import com.hexagonkt.helpers.Logger
import com.hexagonkt.helpers.ensureSize
import com.hexagonkt.helpers.logger
import com.hexagonkt.helpers.stream
Expand Down Expand Up @@ -41,6 +42,9 @@ class AhcAdapter : ClientPort {

private lateinit var ssl: ClientSettings

private val log: Logger = Logger(this)


// TODO Cache this as this will be done in each request
private val ahcClient: DefaultAsyncHttpClient get() =
DefaultAsyncHttpClient(
Expand Down Expand Up @@ -107,7 +111,6 @@ class AhcAdapter : ClientPort {
private fun keyStore(uri: URI, password: String): KeyStore {
val keyStore = KeyStore.getInstance("pkcs12")
keyStore.load(uri.stream(), password.toCharArray())
logger.trace { keyStore }
return keyStore
}

Expand All @@ -128,7 +131,6 @@ class AhcAdapter : ClientPort {
}

val response = ahcRequest.execute().get()
logger.trace { response }

if (settings.useCookies) {
response.cookies.forEach {
Expand All @@ -145,7 +147,6 @@ class AhcAdapter : ClientPort {
.map { it to response.headers.getAll(it) }
.toMap()
)
logger.trace { returnHeaders }

return response.let {
Response(
Expand Down Expand Up @@ -184,13 +185,6 @@ class AhcAdapter : ClientPort {

ssl = cl.settings

logger.trace { method }
logger.trace { path }
logger.trace { settings }
logger.trace { contentType }
logger.trace { parts }
logger.trace { ssl }

val req = when (method) {
GET -> ahcClient.prepareGet(path)
HEAD -> ahcClient.prepareHead(path)
Expand Down Expand Up @@ -218,7 +212,15 @@ class AhcAdapter : ClientPort {
if (authorization != null)
req.addHeader("Authorization", "Basic $authorization")

logger.trace { req }
val info = """
REQUEST METHOD: $method
REQUEST PATH: $path
CLIENT SETTINGS: $settings
CONTENT TYPE: $contentType
SSL: $ssl
""".trimIndent()
log.info { "Request Created: $info" }

return req
}
}

0 comments on commit f9784d8

Please sign in to comment.