Skip to content

Commit ad1e9d3

Browse files
committed
[BOOK-89] chore: 네트워크 통신 로깅 필터링 추가
1 parent 03ac12c commit ad1e9d3

File tree

1 file changed

+22
-1
lines changed
  • core/network/src/main/kotlin/com/ninecraft/booket/core/network/di

1 file changed

+22
-1
lines changed

core/network/src/main/kotlin/com/ninecraft/booket/core/network/di/NetworkModule.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ private val jsonRule = Json {
3333

3434
private val jsonConverterFactory = jsonRule.asConverterFactory("application/json".toMediaType())
3535

36+
private val FILTERED_HEADERS = setOf(
37+
"transfer-encoding",
38+
"connection",
39+
"x-content-type-options",
40+
"x-xss-protection",
41+
"cache-control",
42+
"pragma",
43+
"expires",
44+
"x-frame-options",
45+
"keep-alive",
46+
"server",
47+
"content-length",
48+
)
49+
3650
@Module
3751
@InstallIn(SingletonComponent::class)
3852
internal object NetworkModule {
@@ -56,7 +70,14 @@ internal object NetworkModule {
5670
networkLogAdapter: AndroidLogAdapter,
5771
): HttpLoggingInterceptor {
5872
return HttpLoggingInterceptor { message ->
59-
if (message.isNotBlank()) {
73+
val shouldFilter = FILTERED_HEADERS.any { header ->
74+
message.lowercase().contains("$header:")
75+
}
76+
77+
val isDuplicateContentType = message.lowercase().contains("content-type: application/json") &&
78+
!message.contains("charset")
79+
80+
if (!shouldFilter && !isDuplicateContentType && message.isNotBlank()) {
6081
networkLogAdapter.log(Log.DEBUG, null, message)
6182
}
6283
}.apply {

0 commit comments

Comments
 (0)