Skip to content

Commit 692bc65

Browse files
committed
✨ feat: 웹소켓 로그에 사용자이름 추가
1 parent 2474b2f commit 692bc65

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

backend/src/main/java/io/f1/backend/global/config/StompChannelInterceptor.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@ public Message<?> preSend(Message<?> message, MessageChannel channel) {
2727
throw new IllegalArgumentException("Stomp command required");
2828
}
2929

30+
String username = "알수없는 사용자";
31+
if (accessor.getUser() != null) {
32+
username = accessor.getUser().getName();
33+
}
34+
3035
if (command.equals(StompCommand.CONNECT)) {
31-
log.info("CONNECT : 세션 연결 - sessionId = {}", sessionId);
36+
log.info("user : {} | CONNECT : 세션 연결 - sessionId = {}", username, sessionId);
3237
} else if (command.equals(StompCommand.SUBSCRIBE)) {
3338
if (destination != null && sessionId != null) {
34-
log.info("SUBSCRIBE : 구독 시작 destination = {}", destination);
39+
log.info("user : {} | SUBSCRIBE : 구독 시작 destination = {}", username, destination);
3540
}
3641
} else if (command.equals(StompCommand.SEND)) {
37-
log.info("SEND : 요청 destination = {}", destination);
42+
log.info("user : {} | SEND : 요청 destination = {}", username, destination);
3843
} else if (command.equals(StompCommand.DISCONNECT)) {
39-
log.info("DISCONNECT : 연결 해제 sessionId = {}", sessionId);
44+
log.info("user : {} | DISCONNECT : 연결 해제 sessionId = {}", username, sessionId);
4045
}
4146

4247
return message;

0 commit comments

Comments
 (0)