diff --git a/src/main/kotlin/backend/itracker/logging/aspect/LoggerAspect.kt b/src/main/kotlin/backend/itracker/logging/aspect/LoggerAspect.kt index 00dbc6c..07f0b0a 100644 --- a/src/main/kotlin/backend/itracker/logging/aspect/LoggerAspect.kt +++ b/src/main/kotlin/backend/itracker/logging/aspect/LoggerAspect.kt @@ -51,6 +51,7 @@ class LoggerAspect { - Method: ${request.method} - URI: ${getURI(request)} - IP: ${getClientIP(request)} + - Referer: ${request.getHeader(HttpHeaders.REFERER)} - Signature: ${getSignature(joinPoint)} """.trimIndent() } diff --git a/src/main/kotlin/backend/itracker/tracker/oauth/controller/OauthController.kt b/src/main/kotlin/backend/itracker/tracker/oauth/controller/OauthController.kt index b6b6a0c..bff4e60 100644 --- a/src/main/kotlin/backend/itracker/tracker/oauth/controller/OauthController.kt +++ b/src/main/kotlin/backend/itracker/tracker/oauth/controller/OauthController.kt @@ -4,13 +4,16 @@ import backend.itracker.tracker.oauth.OauthServerType import backend.itracker.tracker.oauth.RedirectType import backend.itracker.tracker.oauth.service.LoginFacade import backend.itracker.tracker.oauth.service.OauthService +import io.github.oshai.kotlinlogging.KotlinLogging import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse +import org.slf4j.MDC import org.springframework.http.HttpHeaders import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* +private val logger = KotlinLogging.logger { } @RestController @RequestMapping("/api/v1/oauth") class OauthController( @@ -25,11 +28,13 @@ class OauthController( response: HttpServletResponse ): ResponseEntity { if (request.getHeader(HttpHeaders.REFERER).contains("localhost")) { + logger.info { "${MDC.get("request_id")} -> code local" } oauthService.getAuthCodeRequestUrl(oauthServerType, RedirectType.LOCAL).let { response.sendRedirect(it) } return ResponseEntity.status(HttpStatus.FOUND).build() } + logger.info { "${MDC.get("request_id")} -> code prod" } oauthService.getAuthCodeRequestUrl(oauthServerType, RedirectType.PROD).let { response.sendRedirect(it) } @@ -44,6 +49,7 @@ class OauthController( request: HttpServletRequest, ): ResponseEntity { if (request.getHeader(HttpHeaders.REFERER).contains("localhost")) { + logger.info { "${MDC.get("request_id")} -> token local" } val accessToken = loginFacade.login(oauthServerType, code, RedirectType.LOCAL) return ResponseEntity.ok() @@ -51,6 +57,7 @@ class OauthController( .build() } + logger.info { "${MDC.get("request_id")} -> token prod" } val accessToken = loginFacade.login(oauthServerType, code, RedirectType.PROD) return ResponseEntity.ok()