11package no.nav.klage.document.config
22
33import no.nav.klage.document.exceptions.MissingAccessException
4- import no.nav.klage.document.util.getSecureLogger
4+ import no.nav.klage.document.util.getLogger
55import org.springframework.http.HttpStatus
66import org.springframework.http.ProblemDetail
77import org.springframework.orm.jpa.JpaObjectRetrievalFailureException
@@ -14,20 +14,19 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep
1414class ProblemHandlingControllerAdvice : ResponseEntityExceptionHandler () {
1515
1616 companion object {
17- private val secureLogger = getSecureLogger()
17+ @Suppress(" JAVA_CLASS_ON_COMPANION" )
18+ private val ourLogger = getLogger(javaClass.enclosingClass)
1819 }
1920
2021 @ExceptionHandler
2122 fun handleEntityNotFound (
2223 ex : JpaObjectRetrievalFailureException ,
23- request : NativeWebRequest
2424 ): ProblemDetail =
2525 create(HttpStatus .NOT_FOUND , ex)
2626
2727 @ExceptionHandler
2828 fun handleMissingAccess (
2929 ex : MissingAccessException ,
30- request : NativeWebRequest
3130 ): ProblemDetail =
3231 create(HttpStatus .FORBIDDEN , ex)
3332
@@ -48,11 +47,11 @@ class ProblemHandlingControllerAdvice : ResponseEntityExceptionHandler() {
4847 private fun logError (httpStatus : HttpStatus , errorMessage : String , exception : Exception ) {
4948 when {
5049 httpStatus.is5xxServerError -> {
51- secureLogger .error(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
50+ ourLogger .error(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
5251 }
5352
5453 else -> {
55- secureLogger .warn(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
54+ ourLogger .warn(" Exception thrown to client: ${httpStatus.reasonPhrase} , $errorMessage " , exception)
5655 }
5756 }
5857 }
0 commit comments