Skip to content

Commit

Permalink
fix: update logback config
Browse files Browse the repository at this point in the history
  • Loading branch information
d1snin committed Apr 23, 2024
1 parent c1a6be3 commit 8462454
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import dev.d1s.beam.bundle.service.IndexService
import dev.d1s.beam.bundle.util.respondHtml
import dev.d1s.beam.client.BeamClient
import dev.d1s.exkt.ktor.server.koin.configuration.Route
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.plugins.*
import io.ktor.server.request.*
Expand Down Expand Up @@ -59,14 +60,9 @@ class IndexRoute : Route, KoinComponent {
}

private suspend fun resolveSpace(call: ApplicationCall): ResolvedSpace {
val url = call.url()
call.log()

logger.i {
val origin = call.request.origin
"New space request on $url from ${origin.remoteAddress}:${origin.remotePort} (${call.request.userAgent() ?: "no user agent"})"
}

val spaceIdentifier = client.resolver.resolveIdentifier(url)
val spaceIdentifier = client.resolver.resolveIdentifier(call.url())

logger.d {
"Space identifier: $spaceIdentifier"
Expand All @@ -76,4 +72,20 @@ class IndexRoute : Route, KoinComponent {

return indexService.resolveSpace(request)
}

private fun ApplicationCall.log() {
logger.i {
val origin = request.origin

val host = origin.remotePort
val port = origin.remotePort

val forwardedHost = request.headers[HttpHeaders.XForwardedHost] ?: "no forwarded host"
val forwardedPort = request.headers[HttpHeaders.XForwardedPort] ?: "no forwarded port"

val userAgent = request.userAgent() ?: "no user agent"

"New space request on ${url()} from $host:$port ($forwardedHost:$forwardedPort) ($userAgent)"
}
}
}

0 comments on commit 8462454

Please sign in to comment.