Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Add logger
Browse files Browse the repository at this point in the history
  • Loading branch information
samithiwat committed Aug 4, 2022
1 parent 3b8c115 commit 516d42b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/app/service/user/user.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,21 @@ func (s *Service) Verify(studentId string, verifyType string) (result bool, err
log.Info().
Str("service", "user").
Str("module", "verify").
Str("type", verifyType).
Str("student_id", studentId).
Msg("Trying to verify the user")

res, errRes := s.client.Verify(ctx, &proto.VerifyUserRequest{StudentId: studentId, VerifyType: verifyType})
if errRes != nil {

log.Error().
Err(errRes).
Str("service", "user").
Str("module", "verify").
Str("type", verifyType).
Str("student_id", studentId).
Msg("Error while verifying")

return false, &dto.ResponseErr{
StatusCode: http.StatusNotFound,
Message: "User not found",
Expand All @@ -190,6 +200,7 @@ func (s *Service) Verify(studentId string, verifyType string) (result bool, err
log.Info().
Str("service", "user").
Str("module", "verify").
Str("type", verifyType).
Str("student_id", studentId).
Msg("Verified the user")

Expand Down Expand Up @@ -402,7 +413,7 @@ func (s *Service) ConfirmEstamp(uid string, eid string) (*proto.ConfirmEstampRes
case codes.Unavailable:
log.Error().
Err(err).
Str("service", "checkin").
Str("service", "estamp").
Str("module", "confirm_estamp").
Msg("Service is down")
return nil, &dto.ResponseErr{
Expand All @@ -425,7 +436,7 @@ func (s *Service) ConfirmEstamp(uid string, eid string) (*proto.ConfirmEstampRes
default:
log.Error().
Err(err).
Str("service", "checkin").
Str("service", "estamp").
Str("module", "confirm_estamp").
Msg("Unhandled error")
return nil, &dto.ResponseErr{
Expand All @@ -436,5 +447,10 @@ func (s *Service) ConfirmEstamp(uid string, eid string) (*proto.ConfirmEstampRes
}
}

log.Info().
Str("service", "estamp").
Str("module", "confirm_estamp").
Msg("Successfully confirm estamp")

return res, nil
}

0 comments on commit 516d42b

Please sign in to comment.