Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat][#4] logging 기능 구현 #16

Merged

Conversation

Stark-Industries0417
Copy link
Collaborator

@Stark-Industries0417 Stark-Industries0417 commented Jan 29, 2025

🔗관련 이슈

✨작업 내용

  • 웹 소켓 요청 및 응답 json 형식으로 기록
  • Logback 정책 설정 적용

@Stark-Industries0417 Stark-Industries0417 self-assigned this Jan 29, 2025
@Stark-Industries0417 Stark-Industries0417 added 👀 s.needs-review 코드 리뷰가 필요한 상태 ✅ s.completed 작업이 완료된 상태 🔥 p.high 높은 우선순위의 이슈 🚀 t.feature 새로운 기능 추가 labels Jan 29, 2025
@Stark-Industries0417 Stark-Industries0417 changed the title Feat/4 logging file output [Feat][#4] logging 기능 구현 Jan 29, 2025
Copy link

@f-lab-saponin f-lab-saponin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!
로깅을 delegate 으로 잘 구현해주셨네요. 👍
코멘트 한 번 확인 부탁드립니다.

private class LoggableWebSocketSession(
private val delegate: WebSocketSession,
private val objectMapper: ObjectMapper
) : WebSocketSession by delegate {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delegate 장점은 무엇인가요? 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존 GameRequestRouter의 구현을 변경하지 않고 추가적인 로직을 삽입할 수 있는 장점이 있습니다

Comment on lines 31 to 48
val logData = mapOf(
"event" to "websocket_request",
"payload" to message.payloadAsText,
"timestamp" to System.currentTimeMillis()
)
logger.info(objectMapper.writeValueAsString(logData))
}

override fun send(messages: Publisher<WebSocketMessage>): Mono<Void> {
return delegate.send(
Flux.from(messages)
.doOnNext { message ->
val logData = mapOf(
"event" to "websocket_response",
"payload" to message.payloadAsText,
"timestamp" to System.currentTimeMillis()
)
logger.info(objectMapper.writeValueAsString(logData))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log 포맷을 json 으로 넣어주었을 때와, 그냥 문자열로 넣었을때랑 장단점을 비교해보면 좋을 것 같네요.

로깅을 사용하는 모든 곳에서 json 으로 일일이 만들어야한다는 단점이 있을 수 있는데,
로그 포맷이 정해져있다면 로그를 받는 쪽에서는 그 포맷만 알면 json 으로 바꾸어서 보내주지 않아도 될 것 같아요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로깅 포맷을 json 으로 설정하기 위한 작업을 진행하였습니다
더불어 로그를 깔끔하게 남기고 싶어 개선 작업도 해보았습니다 ☺️
개선 과정은 블로그에 작성해 보았습니다 감사합니다
https://dipp-techjourney.tistory.com/9

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깊은 고민을 하셨군요! 고생하셨습니다. 덕분에 내부 구조를 잘 이해하신것같네요. 👍

제가 코멘트 드린 부분은 아래와 같이 로그백에 제공해주는 포맷으로 하면 편할 것 같다는 의견이었는데 아래와 같은 양식도 한번 참고해주세요 😀

<encoder>
  <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogstashEncoder 의존성 없이 깔끔하게 로그를 볼 수 있는 장점이 있군요
감사합니다 :)

Copy link

@f-lab-saponin f-lab-saponin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마지막 리뷰와 소나큐브 한번 확인부탁드릴게요!

Copy link

sonarqubecloud bot commented Feb 3, 2025

Copy link

@f-lab-saponin f-lab-saponin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로깅 기능 구현 고생하셨습니다 👍

@Stark-Industries0417 Stark-Industries0417 merged commit aa22543 into feat/13-enemy-follow-player Feb 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥 p.high 높은 우선순위의 이슈 ✅ s.completed 작업이 완료된 상태 👀 s.needs-review 코드 리뷰가 필요한 상태 🚀 t.feature 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants