Skip to content

Commit

Permalink
Merge pull request #939 from hmrc/DL-8876
Browse files Browse the repository at this point in the history
[DL-8876] revise logging
  • Loading branch information
derickdamoah authored Oct 18, 2022
2 parents 6b0bff0 + d787881 commit 5ecf8cd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/utils/LegacyErrorHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LegacyErrorHandler @Inject()(env: Environment,
case _: NotImplementedException =>
NotImplemented(Json.toJson(DownstreamError))
case _ =>
logger.info(s"[LegacyErrorHandler][onServerError] uncaught 5xx Exception")
logger.warn(s"[LegacyErrorHandler][onServerError] uncaught 5xx Exception")
result
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/v1/controllers/requestParsers/RequestParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ trait RequestParser[Raw <: RawData, Request] extends Logging {
def parseRequest(data: Raw)(implicit correlationId: String): Either[ErrorWrapper, Request] = {
validator.validate(data) match {
case Nil =>
logger.info(message = "[RequestParser][parseRequest] " +
logger.debug(message = "[RequestParser][parseRequest] " +
s"Validation successful for the request with correlationId : $correlationId")
Right(requestFor(data))
case err :: Nil =>
logger.info(message = "[RequestParser][parseRequest] " +
logger.debug(message = "[RequestParser][parseRequest] " +
s"Validation failed with ${err.code} error for the request with correlationId : $correlationId")
Left(ErrorWrapper(correlationId, err, None))
case errs =>
logger.info("[RequestParser][parseRequest] " +
logger.debug("[RequestParser][parseRequest] " +
s"Validation failed with ${errs.map(_.code).mkString(",")} errors for the request with correlationId : $correlationId")
Left(ErrorWrapper(correlationId, BadRequestError, Some(errs)))
}
Expand Down
4 changes: 2 additions & 2 deletions app/v1/nrs/NrsConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class NrsConnector @Inject()(val httpClient: HttpClient,
}

retry(appConfig.nrsRetries, retryCondition) { attemptNumber =>
logger.info(s"Attempt $attemptNumber NRS submission: sending POST request to $url")
logger.info(s"Attempt $attemptNumber NRS submission: sending POST request to $url. CorrelationId: $correlationId")

httpClient
.POST[NrsSubmission, HttpResponse](url, nrsSubmission, Seq("X-API-Key" -> apiKey))
.map { response =>
val status = response.status

if (Status.isSuccessful(status)) {
logger.info("NRS submission successful")
logger.info(s"NRS submission successful. CorrelationId: $correlationId")
Right(response.json.as[NrsResponse])
} else {
logger.warn(s".CorrelationId: $correlationId\tRequestId:${hc.requestId}\nNRS submission failed with error: ${response.body}")
Expand Down
10 changes: 5 additions & 5 deletions app/v1/services/EnrolmentsAuthService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class EnrolmentsAuthService @Inject()(val connector: AuthConnector) extends Logg
case Some(Individual) ~ enrolments => createUserDetailsWithLogging(affinityGroup = "Individual", enrolments)
case Some(Organisation) ~ enrolments => createUserDetailsWithLogging(affinityGroup = "Organisation", enrolments)
case Some(Agent) ~ enrolments => createUserDetailsWithLogging(affinityGroup = "Agent", enrolments)
case _ =>
logger.warn(s"[AuthorisationService] [authoriseAsClient] Authorisation failed due to unsupported affinity group.")
case affinityGroup =>
logger.warn(s"[AuthorisationService] [authoriseAsClient] Authorisation failed due to unsupported affinity group. $affinityGroup")
Future.successful(Left(LegacyUnauthorisedError))
}recoverWith unauthorisedError
} else {
Expand Down Expand Up @@ -77,8 +77,8 @@ class EnrolmentsAuthService @Inject()(val connector: AuthConnector) extends Logg
)

createUserDetailsWithLogging(affinityGroup = affGroup.get.toString, enrolments, Some(identityData))
case _ =>
logger.warn(s"[EnrolmentsAuthService] [authorised with nrsRequired = true] Authorisation failed due to unsupported affinity group.")
case affinityGroup =>
logger.warn(s"[EnrolmentsAuthService] [authorised with nrsRequired = true] Authorisation failed due to unsupported affinity group. $affinityGroup")
Future.successful(Left(LegacyUnauthorisedError))

}recoverWith unauthorisedError
Expand All @@ -91,7 +91,7 @@ class EnrolmentsAuthService @Inject()(val connector: AuthConnector) extends Logg
identityData: Option[IdentityData] = None): Future[Right[MtdError, UserDetails]] = {

val clientReference = getClientReferenceFromEnrolments(enrolments)
logger.info(s"[AuthorisationService] [authoriseAsClient] Authorisation succeeded as" +
logger.debug(s"[AuthorisationService] [authoriseAsClient] Authorisation succeeded as" +
s"fully-authorised organisation for VRN $clientReference.")

val userDetails = UserDetails(
Expand Down
2 changes: 1 addition & 1 deletion app/v1/support/DesResponseMappingSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait DesResponseMappingSupport {
implicit logContext: EndpointLogContext): ErrorWrapper = {

lazy val defaultErrorCodeMapping: String => MtdError = { code =>
logger.info(s"[${logContext.controllerName}] [${logContext.endpointName}] - No mapping found for error code $code")
logger.warn(s"[${logContext.controllerName}] [${logContext.endpointName}] - No mapping found for error code $code")
DownstreamError
}

Expand Down

0 comments on commit 5ecf8cd

Please sign in to comment.