Skip to content

Commit b7353e9

Browse files
committed
chore: GameRecoveryService 로깅 수준 info에서 debug로 변경
- 복구 메시지 저장, 조회 시 로깅 수준을 debug로 조정하여 로그 노이즈 감소 - 중요하지 않은 로깅 항목의 가독성 및 유지보수성 향상
1 parent 7d1816b commit b7353e9

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

backend/src/main/java/coffeeshout/global/websocket/GameRecoveryService.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
import org.springframework.util.DigestUtils;
2323

2424
/**
25-
* 웹소켓 메시지 복구 서비스
26-
* Redis Stream을 활용하여 메시지를 백업하고 복구 기능을 제공합니다.
25+
* 웹소켓 메시지 복구 서비스 Redis Stream을 활용하여 메시지를 백업하고 복구 기능을 제공합니다.
2726
*/
2827
@Slf4j
2928
@Service
@@ -65,29 +64,29 @@ public GameRecoveryService(
6564
local maxLen = tonumber(ARGV[5])
6665
local streamTtl = tonumber(ARGV[6])
6766
local dedupTtl = tonumber(ARGV[7])
68-
67+
6968
-- 중복 체크: 이미 저장된 메시지인지 확인
7069
local existingStreamId = redis.call('HGET', idMapKey, messageId)
7170
if existingStreamId then
7271
return existingStreamId -- 기존 streamId 반환
7372
end
74-
73+
7574
-- Stream에 저장
7675
local streamId = redis.call('XADD', streamKey, 'MAXLEN', '~', maxLen, '*',
7776
'destination', destination,
7877
'payload', payloadJson,
7978
'timestamp', timestamp
8079
)
81-
80+
8281
-- messageId → streamId 매핑 저장 (짧은 TTL로 중복 방지)
8382
redis.call('HSET', idMapKey, messageId, streamId)
8483
redis.call('EXPIRE', idMapKey, dedupTtl)
85-
84+
8685
-- Stream TTL 설정 (처음 생성 시에만)
8786
if redis.call('TTL', streamKey) == -1 then
8887
redis.call('EXPIRE', streamKey, streamTtl)
8988
end
90-
89+
9190
return streamId
9291
""";
9392

@@ -97,9 +96,9 @@ public GameRecoveryService(
9796
/**
9897
* 메시지를 Recovery Stream에 저장 (중복 방지)
9998
*
100-
* @param joinCode 방 코드
99+
* @param joinCode 방 코드
101100
* @param destination 웹소켓 destination
102-
* @param response WebSocketResponse
101+
* @param response WebSocketResponse
103102
* @return Redis Stream Entry ID (예: "1234567890-0"), 중복인 경우에도 기존 streamId 반환
104103
*/
105104
public String save(JoinCode joinCode, String destination, WebSocketResponse<?> response) {
@@ -125,7 +124,7 @@ public String save(JoinCode joinCode, String destination, WebSocketResponse<?> r
125124
String.valueOf(dedupTtlSeconds)
126125
);
127126

128-
log.info("복구 메시지 저장: joinCode={}, streamId={}, messageId={}", joinCode, streamId, messageId);
127+
log.debug("복구 메시지 저장: joinCode={}, streamId={}, messageId={}", joinCode, streamId, messageId);
129128

130129
return streamId;
131130

@@ -141,7 +140,7 @@ public String save(JoinCode joinCode, String destination, WebSocketResponse<?> r
141140
/**
142141
* lastStreamId 이후의 메시지 조회 (XRANGE 활용)
143142
*
144-
* @param joinCode 방 코드
143+
* @param joinCode 방 코드
145144
* @param lastStreamId 클라이언트가 마지막으로 받은 Redis Stream Entry ID (예: "1234567890-0")
146145
* @return 복구 메시지 리스트
147146
*/
@@ -157,7 +156,7 @@ public List<RecoveryMessage> getMessagesSince(JoinCode joinCode, String lastStre
157156
.range(streamKey, Range.open(lastStreamId, "+"));
158157

159158
if (records == null || records.isEmpty()) {
160-
log.info("복구 메시지 없음: joinCode={}, lastStreamId={}", joinCode, lastStreamId);
159+
log.debug("복구 메시지 없음: joinCode={}, lastStreamId={}", joinCode, lastStreamId);
161160
return List.of();
162161
}
163162

@@ -166,7 +165,7 @@ public List<RecoveryMessage> getMessagesSince(JoinCode joinCode, String lastStre
166165
.filter(Objects::nonNull)
167166
.toList();
168167

169-
log.info("복구 메시지 조회: joinCode={}, lastStreamId={}, count={}", joinCode, lastStreamId, messages.size());
168+
log.debug("복구 메시지 조회: joinCode={}, lastStreamId={}, count={}", joinCode, lastStreamId, messages.size());
170169
return messages;
171170

172171
} catch (Exception e) {

0 commit comments

Comments
 (0)