-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feat][#4] logging 기능 구현 #16
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delegate 장점은 무엇인가요? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 GameRequestRouter의 구현을 변경하지 않고 추가적인 로직을 삽입할 수 있는 장점이 있습니다
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log 포맷을 json 으로 넣어주었을 때와, 그냥 문자열로 넣었을때랑 장단점을 비교해보면 좋을 것 같네요.
로깅을 사용하는 모든 곳에서 json 으로 일일이 만들어야한다는 단점이 있을 수 있는데,
로그 포맷이 정해져있다면 로그를 받는 쪽에서는 그 포맷만 알면 json 으로 바꾸어서 보내주지 않아도 될 것 같아요.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogstashEncoder 의존성 없이 깔끔하게 로그를 볼 수 있는 장점이 있군요
감사합니다 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마지막 리뷰와 소나큐브 한번 확인부탁드릴게요!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로깅 기능 구현 고생하셨습니다 👍
aa22543
into
feat/13-enemy-follow-player
🔗관련 이슈
✨작업 내용