-
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
Handle logging #22
Handle logging #22
Conversation
...3/src/main/kotlin/com/vndevteam/kotlinwebspringboot3/infrastructure/logging/RequestFilter.kt
Outdated
Show resolved
Hide resolved
kotlin-web-spring-boot-3/src/main/kotlin/com/vndevteam/kotlinwebspringboot3/util/MapperUtils.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/com/vndevteam/kotlinwebspringboot3/infrastructure/logging/CustomResponseBody.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/com/vndevteam/kotlinwebspringboot3/infrastructure/logging/CustomResponseBody.kt
Outdated
Show resolved
Hide resolved
56550b8
to
149dfa3
Compare
} else { | ||
UUID.randomUUID().toString() | ||
} | ||
return clientId |
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.
Thấy ở đây ngta có override thêm 2 method isAsyncDispatch
và shouldNotFilterErrorDispatch
hình như là để apply cho request lỗi. Hải check thử có cần thêm vào không nhé @haiks-2382
https://github.com/Verdoso/GreenSummer/blob/master/summer-core/src/main/java/org/greeneyed/summer/filter/Slf4jMDCFilter.java#L111
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.
t thêm rồi nhé,. Xem qua docs thì isAsyncDispatch là kiểu khi filter đc gọi từ 1 async dispatch thì mặc định sẽ ko call func doFilterInternal. shouldNotFilterErrorDispatch thì cũng tương tự mặc định ko call tới doFilterInternal, cụ thể liên quan tới việc response error nếu dùng thymleaf thì phải
...ot-3/src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/RequestFilter.kt
Outdated
Show resolved
Hide resolved
...kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/Slf4jMDCFilterConfiguration.kt
Outdated
Show resolved
Hide resolved
...ot-3/src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/RequestFilter.kt
Outdated
Show resolved
Hide resolved
...ot-3/src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/RequestFilter.kt
Outdated
Show resolved
Hide resolved
...ot-3/src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/RequestFilter.kt
Outdated
Show resolved
Hide resolved
...kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/Slf4jMDCFilterConfiguration.kt
Outdated
Show resolved
Hide resolved
@Configuration | ||
class Slf4jMDCFilterConfiguration { | ||
companion object { | ||
const val DEFAULT_RESPONSE_TOKEN_HEADER = "client_id" |
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.
const val DEFAULT_RESPONSE_TOKEN_HEADER = "client_id" | |
const val DEFAULT_RESPONSE_TOKEN_HEADER = "X-Client-Id" |
...src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/CustomResponseBody.kt
Outdated
Show resolved
Hide resolved
...src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/CustomResponseBody.kt
Outdated
Show resolved
Hide resolved
...ot-3/src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/RequestFilter.kt
Outdated
Show resolved
Hide resolved
body: Any? | ||
) { | ||
val requestId = httpServletRequest.getAttribute(RequestFilter.REQUEST_ID) | ||
if (requestId != null) { |
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.
@haiks-2382 Phần log response time này Hải tách ra thành 1 filter khác như bài này nhé: https://stackoverflow.com/a/42858002/5718493
Để sau này mình dễ dàng bật tắt, đảm bảo các chức năng đc tách bạch không dồn chung vào 1 file
...src/main/kotlin/com/vndevteam/kotlinwebspringboot3/application/logging/CustomResponseBody.kt
Outdated
Show resolved
Hide resolved
149dfa3
to
a433a9c
Compare
a433a9c
to
7881823
Compare
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.
LGTM
Summary
Handle logging
Description
#17
![image](https://private-user-images.githubusercontent.com/75669882/279432446-2d3b6167-a258-406f-846c-0f983abdcfa6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg3ODI0NTAsIm5iZiI6MTczODc4MjE1MCwicGF0aCI6Ii83NTY2OTg4Mi8yNzk0MzI0NDYtMmQzYjYxNjctYTI1OC00MDZmLTg0NmMtMGY5ODNhYmRjZmE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA1VDE5MDIzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM3MTQzM2JkOWQwMzhhZWM3YzExNWZkYzY0OGUzOThiZmQwZmRhZjBiNjk2YmJlYWRiZjMyZmFjZGM0NmYxZWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.NI2vk0ecYvyQAbErZSXS3cu9cSJNfH-gUliX9oJfPr4)
Checklist
Evidence
(Screenshot or Video)
Discussion
Note the part that you are not sure. Comment on your code is OK.