Skip to content

Commit 6cc3a96

Browse files
committed
fix: FCM 토큰 로그 마스킹
1 parent e66e016 commit 6cc3a96

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/main/java/com/semosan/api/domain/notification/dispatcher/AsyncNotificationDispatcher.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void dispatch(NotificationDispatchCommand cmd) {
3535
} catch (FirebaseMessagingException e) {
3636
handleSendError(token, e);
3737
} catch (Exception e) {
38-
log.error("FCM 발송 중 알 수 없는 에러 (token={}): {}", token, e.getMessage(), e);
38+
log.error("FCM 발송 중 알 수 없는 에러 (token={}): {}", maskToken(token), e.getMessage(), e);
3939
}
4040
}
4141
}
@@ -59,10 +59,18 @@ private Map<String, String> buildDataPayload(NotificationDispatchCommand cmd) {
5959
private void handleSendError(String token, FirebaseMessagingException e) {
6060
MessagingErrorCode code = e.getMessagingErrorCode();
6161
if (code == MessagingErrorCode.UNREGISTERED || code == MessagingErrorCode.INVALID_ARGUMENT) {
62-
log.warn("만료/잘못된 토큰 삭제 (token={}, code={})", token, code);
62+
log.warn("만료/잘못된 토큰 삭제 (token={}, code={})", maskToken(token), code);
6363
fcmTokenService.deleteExpired(token);
6464
} else {
65-
log.error("FCM 발송 실패 (token={}, code={}): {}", token, code, e.getMessage());
65+
log.error("FCM 발송 실패 (token={}, code={}): {}", maskToken(token), code, e.getMessage());
6666
}
6767
}
68+
69+
private String maskToken(String token) {
70+
if (token == null || token.isBlank()) {
71+
return "<empty>";
72+
}
73+
int visibleLength = Math.min(8, token.length());
74+
return token.substring(0, visibleLength) + "***";
75+
}
6876
}

0 commit comments

Comments
 (0)