Skip to content

Commit 911515b

Browse files
s-hwanhwangjokim
authored andcommitted
trivial:유의미한 데이터를 log 로 남기기 (#338)
* group 수정 * notice log * problem log 수정 * solution log 수정 * user log 수정 * trivial:user,problem log 수정 * trivial : noti log 수정 * trivial:notice log 수정 * trivial:group log 수정 * trivial:merge develop branch
1 parent 119d2cd commit 911515b

File tree

9 files changed

+36
-31
lines changed

9 files changed

+36
-31
lines changed

src/main/java/com/gamzabat/algohub/feature/group/studygroup/service/StudyGroupService.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public GroupCodeResponse createGroup(User user, CreateGroupRequest request, Mult
121121
);
122122

123123
saveGroupImage(profileImage, group);
124-
log.info("success to save study group");
124+
log.info("success to save study group user_id={}", user.getId());
125125
return new GroupCodeResponse(inviteCode);
126126
}
127127

@@ -154,7 +154,7 @@ public GetGroupIdResponse joinGroupWithCode(User user, String code) {
154154
);
155155

156156
sendNewMemberNotification(studyGroup, member);
157-
log.info("success to join study group");
157+
log.info("success to join study group user_id={} code = {} ", user.getId(), code);
158158

159159
return new GetGroupIdResponse(studyGroup.getId());
160160

@@ -175,7 +175,7 @@ public void deleteGroup(User user, Long groupId) {
175175

176176
deleteAllAboutGroup(group);
177177

178-
log.info("success to delete study group");
178+
log.info("success to delete study group user_id={}, group_id={}", user.getId(), groupId);
179179
}
180180

181181
private void deleteAllAboutGroup(StudyGroup group) {
@@ -216,7 +216,7 @@ public void exitGroup(User user, Long groupId) {
216216
}
217217
}
218218

219-
log.info("success to exit study group");
219+
log.info("success to exit study group user_id = {} , group_id = {}", user.getId(), groupId);
220220
}
221221

222222
@Transactional
@@ -237,6 +237,7 @@ public void deleteMember(User user, Long userId, Long groupId) {
237237
() -> new GroupMemberValidationException(HttpStatus.BAD_REQUEST.value(), "이미 참여하지 않은 회원입니다."));
238238

239239
studyGroupServiceProvider.getObject().deleteMemberFromStudyGroup(user, groupMember, group);
240+
log.info("success to delete member user_id={} , group_id = {}", user.getId(), groupId);
240241
} else {
241242
throw new UserValidationException("멤버를 삭제 할 권한이 없습니다.");
242243
}
@@ -250,7 +251,7 @@ public void deleteMemberFromStudyGroup(User user, GroupMember groupMember, Study
250251
solutionRepository.deleteAllByStudyGroupAndUser(studyGroup, user);
251252
noticeReadRepository.deleteAllByStudyGroupAndUser(studyGroup, user);
252253
groupMemberRepository.delete(groupMember);
253-
log.info("success to delete group member");
254+
log.info("success to delete group member user_id = {}, group_id = {}", user.getId(), studyGroup.getId());
254255
}
255256

256257
@Transactional(readOnly = true)
@@ -336,7 +337,7 @@ public void editGroup(User user, Long groupId, EditGroupRequest request, Multipa
336337
if (request.introduction() != null && !request.introduction().isEmpty())
337338
group.editGroupIntroduction(request.introduction());
338339

339-
log.info("success to edit group info");
340+
log.info("success to edit group info user_id={} , group_id = {}", user.getId(), groupId);
340341
}
341342

342343
private void editGroupImage(MultipartFile inputImage, StudyGroup group, Boolean isDefaultImage) {
@@ -534,7 +535,7 @@ public void updateGroupMemberRole(User user, Long groupId, UpdateGroupMemberRole
534535
if (RoleOfGroupMember.isOwner(member) && request.role() != null) {
535536
owner.updateRole(RoleOfGroupMember.PARTICIPANT);
536537
}
537-
log.info("success to update group member role");
538+
log.info("success to update group member role user_id={} , group_id = {}", user.getId(), group.getId());
538539
}
539540

540541
@Transactional(readOnly = true)
@@ -556,7 +557,7 @@ public void editStudyGroupVisibility(User user, Long groupId, EditGroupVisibilit
556557
GroupMember member = groupMemberRepository.findByUserAndStudyGroup(user, group)
557558
.orElseThrow(() -> new GroupMemberValidationException(HttpStatus.FORBIDDEN.value(), "참여하지 않은 그룹입니다."));
558559
member.updateVisibility(request.isVisible());
559-
log.info("success to update group visibility ( userId : {} )", user.getId());
560+
log.info("success to update group visibility user_id = {}, group_id = {}", user.getId(), groupId);
560561
}
561562

562563
@Transactional(readOnly = true)

src/main/java/com/gamzabat/algohub/feature/notice/service/NoticeCommentService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public void createComment(User user, Long noticeId, CreateNoticeCommentRequest r
4848
.content(request.content())
4949
.build());
5050

51-
log.info("success to create notice comment. commentId: {}, noticeId: {}", comment.getId(), notice.getId());
51+
log.info("success to create notice comment. comment_id = {}, notice_id = {}", comment.getId(), notice.getId());
5252
}
5353

5454
@Override
5555
@Transactional(readOnly = true)
5656
public List<GetCommentResponse> getCommentList(User user, Long noticeId) {
5757
Notice notice = validateNotice(user, noticeId);
5858
List<NoticeComment> notices = noticeCommentRepository.findAllByNotice(notice);
59-
log.info("success to get notice comment list. noticeId: {}", noticeId);
59+
log.info("success to get notice comment list. notice_id = {}", noticeId);
6060
return notices.stream().map(GetCommentResponse::toDTO).sorted(Comparator.comparing(
6161
GetCommentResponse::createdAt).reversed()).toList();
6262
}
@@ -70,10 +70,10 @@ public void updateComment(User user, Long commentId, UpdateCommentRequest reques
7070
if (!comment.getUser().getId().equals(user.getId()))
7171
throw new UserValidationException("댓글 작성자만 수정할 수 있습니다.");
7272

73-
if(request.content()!=null){
73+
if (request.content() != null) {
7474
comment.updateComment(request.content());
7575
}
76-
log.info("success to update notice comment. commentId: {}", comment.getId());
76+
log.info("success to update notice comment. comment_id = {}", comment.getId());
7777

7878
}
7979

@@ -88,7 +88,7 @@ public void deleteComment(User user, Long commentId) {
8888

8989
validateNotice(user, comment.getNotice().getId());
9090
noticeCommentRepository.delete(comment);
91-
log.info("success to delete notice comment. commentId: {}", commentId);
91+
log.info("success to delete notice comment. comment_id = {}", commentId);
9292

9393
}
9494

src/main/java/com/gamzabat/algohub/feature/notice/service/NoticeService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public CreateNoticeResponse createNotice(@AuthedUser User user, Long groupId, Cr
6363
.category(request.category())
6464
.createdAt(LocalDateTime.now())
6565
.build());
66-
log.info("success to create notice");
66+
log.info("success to create notice user_id={} , group_id = {}", user.getId(), groupId);
6767
return new CreateNoticeResponse(notice.getId());
6868
}
6969

@@ -99,7 +99,7 @@ public void markNoticeAsRead(@AuthedUser User user, Long noticeId) {
9999
NoticeRead.builder().notice(notice).user(user).build()
100100
);
101101
}
102-
log.info("success to read notice. userId: {}, noticeId: {}", user.getId(), notice.getId());
102+
log.info("success to read notice. user_id = {}, notice_id = {}", user.getId(), notice.getId());
103103
}
104104

105105
@Transactional(readOnly = true)
@@ -132,7 +132,7 @@ public void updateNotice(User user, Long noticeId, UpdateNoticeRequest request)
132132
if (request.category() != null) {
133133
notice.updateCategory(request.category());
134134
}
135-
log.info("success to update notice");
135+
log.info("success to update notice user_id={} , notice_id = {}", user.getId(), noticeId);
136136
}
137137

138138
@Transactional
@@ -148,7 +148,7 @@ public void deleteNotice(User user, Long noticeId) {
148148
noticeReadRepository.deleteAllByNotice(notice);
149149
noticeRepository.delete(notice);
150150

151-
log.info("success to delete notice. userId: {}, noticeId: {}", user.getId(), noticeId);
151+
log.info("success to delete notice. user_id = {}, notice_id = {}", user.getId(), noticeId);
152152
}
153153

154154
private void validateStudyGroupExists(Notice notice) {

src/main/java/com/gamzabat/algohub/feature/notification/service/NotificationService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public void readNotification(User user, Long notificationId) {
182182
if (!notification.getUser().getId().equals(user.getId()))
183183
throw new NotificationValidationException(HttpStatus.FORBIDDEN.value(), "알림의 주인이 일치하지 않습니다.");
184184
notification.updateIsRead();
185-
log.info("success to read notification. notificationId : {}", notificationId);
185+
log.info("success to read notification. notification_id = {}", notificationId);
186186
}
187187

188188
@Transactional
@@ -193,7 +193,7 @@ public void sendNotificationToMembers(StudyGroup group, List<GroupMember> receiv
193193
for (GroupMember member : receiver) {
194194
NotificationSetting setting = notificationSettingRepository.findByMember(member)
195195
.orElseThrow(() -> {
196-
log.error("cannot find notification setting for member. userId : {}, groupId : {}",
196+
log.error("cannot find notification setting for member. user_id = {}, group_id =g {}",
197197
member.getUser().getId(), group.getId());
198198
return new CannotFoundNotificationSettingException("해당 그룹에 가입 되지 않은 유저입니다.");
199199
});

src/main/java/com/gamzabat/algohub/feature/notification/service/NotificationSettingService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public void editNotificationSettings(User user, EditNotificationSettingRequest r
5353
request.deadlineReached()
5454
);
5555

56-
log.info("success to edit notification settings");
56+
log.info("success to edit notification settings user_id = {}", user.getId());
5757
}
5858
}

src/main/java/com/gamzabat/algohub/feature/problem/service/ProblemService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void createProblem(User user, Long groupId, CreateProblemRequest request)
9191
NotificationCategory.PROBLEM_STARTED.getMessage(title)
9292
);
9393

94-
log.info("success to create problem");
94+
log.info("success to create problem user_id={} , group_id = {}", user.getId(), groupId);
9595
}
9696

9797
@Transactional
@@ -118,7 +118,7 @@ public void editProblem(User user, Long problemId, EditProblemRequest request) {
118118
problem.editProblemEndDate(request.endDate());
119119
}
120120

121-
log.info("success to edit problem deadline");
121+
log.info("success to edit problem deadline user_id={} , problem_id = {}", user.getId(), problemId);
122122
}
123123

124124
private void checkProblemValidation(Problem problem) {
@@ -212,7 +212,7 @@ public void deleteProblem(User user, Long problemId) {
212212

213213
solutionRepository.deleteAllByProblem(problem);
214214
problemRepository.delete(problem);
215-
log.info("success to delete problem");
215+
log.info("success to delete problem user_id={} , problem_id = {}", user.getId(), problemId);
216216
}
217217

218218
@Transactional(readOnly = true)

src/main/java/com/gamzabat/algohub/feature/solution/service/SolutionCommentService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void createComment(User user, Long solutionId, CreateSolutionCommentReque
5757
.build());
5858

5959
sendCommentNotification(user, solution);
60-
log.info("success to create solution comment. commentId: {}, solutionId: {}", comment.getId(),
60+
log.info("success to create solution comment. comment_id = {}, solution_id = {}", comment.getId(),
6161
solution.getId());
6262
}
6363

@@ -88,7 +88,7 @@ public List<GetCommentResponse> getCommentList(User user, Long solutionId) {
8888
}
8989
List<GetCommentResponse> result = list.stream().map(GetCommentResponse::toDTO)
9090
.sorted((s1, s2) -> s2.createdAt().compareTo(s1.createdAt())).toList();
91-
log.info("success to get solution comment list. solutionId: {}", solutionId);
91+
log.info("success to get solution comment list. solution_id = {} , user_id = {}", solutionId, user.getId());
9292
return result;
9393
}
9494

@@ -101,7 +101,7 @@ public void updateComment(User user, Long commentId, UpdateCommentRequest reques
101101
throw new UserValidationException("댓글 작성자가 아닙니다.");
102102

103103
comment.updateComment(request.content());
104-
log.info("success to update solution comment. commentId: {}", commentId);
104+
log.info("success to update solution comment. comment_id = {}, user_id = {}", commentId, user.getId());
105105
}
106106

107107
@Override
@@ -114,7 +114,7 @@ public void deleteComment(User user, Long commentId) {
114114

115115
checkSolutionValidation(user, comment.getSolution().getId());
116116
commentRepository.delete(comment);
117-
log.info("success to delete solution comment. commentId: {}", commentId);
117+
log.info("success to delete solution comment. comment_id = {}, user_id = {}", commentId, user.getId());
118118
}
119119

120120
private Solution checkSolutionValidation(User user, Long solutionId) {

src/main/java/com/gamzabat/algohub/feature/solution/service/SolutionService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ public void createSolution(CreateSolutionRequest request) {
241241

242242
sendNewSolutionNotification(studyGroup, member.get(), problem);
243243
}
244+
log.info("success to create solution user_id={}.", user.getId());
244245
}
245246

246247
private void sendNewSolutionNotification(StudyGroup group, GroupMember solver, Problem problem) {

src/main/java/com/gamzabat/algohub/feature/user/service/UserService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void register(RegisterRequest request, MultipartFile profileImage, String
9292
.build());
9393

9494
saveProfileImage(profileImage, user);
95-
log.info("success to register");
95+
log.info("success to register user_id={}", user.getId());
9696
}
9797

9898
private void saveProfileImage(MultipartFile profileImage, User user) {
@@ -113,7 +113,7 @@ public TokenResponse signIn(SignInRequest request) {
113113
throw new UncorrectedPasswordException("비밀번호가 틀렸습니다.");
114114
}
115115
JwtDTO result = tokenProvider.generateTokens(authenticate);
116-
log.info("success to sign in");
116+
log.info("success to sign in identifier = {}", request.identifier());
117117
return new TokenResponse(result.getAccessToken(), result.getRefreshToken());
118118
}
119119

@@ -144,7 +144,7 @@ public void userUpdate(User user, UpdateUserRequest updateUserRequest, Multipart
144144
}
145145

146146
userRepository.save(user);
147-
log.info("success to update user");
147+
log.info("success to update user user_id={}", user.getId());
148148
}
149149

150150
private void editUserProfileImage(User user, MultipartFile inputImage, Boolean isDefaultImage) {
@@ -179,6 +179,7 @@ public void deleteUser(User user, DeleteUserRequest deleteUserRequest) {
179179
throw new UncorrectedPasswordException("비밀번호가 틀렸습니다.");
180180
}
181181
userRepository.delete(user);
182+
log.info("success to delete user user_id={}", user.getId());
182183
}
183184

184185
@Transactional
@@ -199,6 +200,7 @@ public void editPassword(User user, EditUserPasswordRequest request) {
199200
user.editPassword(encodedPassword);
200201

201202
userRepository.save(user);
203+
log.info("success to edit password user_id={}", user.getId());
202204
}
203205

204206
@Transactional
@@ -229,6 +231,7 @@ public void deleteBjNickname(User user) {
229231
public void checkEmailDuplication(String email) {
230232
if (userRepository.existsByEmail(email))
231233
throw new UserValidationException("이미 사용 중인 이메일 입니다.");
234+
log.info("success to validity email = {}", email);
232235
}
233236

234237
@Transactional(readOnly = true)
@@ -243,7 +246,7 @@ public void checkNickname(String nickname) {
243246
if (userRepository.existsByNickname(nickname))
244247
throw new CheckNicknameValidationException(HttpStatus.CONFLICT.value(), "이미 사용 중인 닉네임입니다.");
245248

246-
log.info("success to check nickname validity");
249+
log.info("success to check nickname validity nickname={}", nickname);
247250
}
248251

249252
@Transactional(readOnly = true)

0 commit comments

Comments
 (0)