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

build type에 따른 httpinterceptor Logging #93

Merged
merged 4 commits into from
Nov 15, 2023

Conversation

2taezeat
Copy link
Collaborator

@2taezeat 2taezeat commented Nov 15, 2023

Issue

Overview

#76 (comment)

실험 해본 결과

  • httpLoggingInterceptor 에서 따로 처리를 해야만, release build 시에 Log 가 출력 안되는 걸로 확인되었습니다.
    • 코멘트 주신대로 그 부분 처리했습니다.
  • timber_log_format 도 약간 수정했습니다 ('/' 가 있으면 좀 다르게 출력되어 뺐습니다.)

@2taezeat 2taezeat requested a review from youlalala November 15, 2023 14:34
@2taezeat 2taezeat linked an issue Nov 15, 2023 that may be closed by this pull request
@2taezeat 2taezeat added the ✨ feat 기능 개발 label Nov 15, 2023
@2taezeat 2taezeat self-assigned this Nov 15, 2023
@2taezeat 2taezeat added this to the 🔧 etc milestone Nov 15, 2023
@2taezeat 2taezeat requested a review from HamBP November 15, 2023 14:35
Copy link

github-actions bot commented Nov 15, 2023

Test Results

0 tests   0 ✔️  0s ⏱️
0 suites  0 💤
0 files    0

Results for commit 5e48529.

♻️ This comment has been updated with latest results.

@2taezeat 2taezeat changed the title feat : httpLoggingInterceptor, Debug build 때만, Logging 출력 build type에 따른 httpinterceptor Logging Nov 15, 2023
val httpLoggingInterceptor = HttpLoggingInterceptor().apply {
level = if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE
}

Copy link
Member

Choose a reason for hiding this comment

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

Timber 를 적용했던 이유가 httplogging 할 때, debug 일때만 Log 찍히게 하기 위해서 적용했었는데, 지금 처럼 따로 if 문으로 적용해줄거면 Timber 를 사용하는 이유가 없어지는 것 같습니당! https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor 처럼 timber 로 log를 찍게 해야할 것 같습니다 ~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반영했습니다~

Copy link
Member

@HamBP HamBP left a comment

Choose a reason for hiding this comment

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

고생했어~
코멘트 해결하고 머지하면 될 거 같아

@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {

@Singleton
@Provides
fun provideOkHttpClient(): OkHttpClient {
val httpLoggingInterceptor = HttpLoggingInterceptor()
val logger = HttpLoggingInterceptor.Logger { message -> Timber.tag("okHttp").d(message) }
Copy link
Member

@HamBP HamBP Nov 15, 2023

Choose a reason for hiding this comment

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

String.format(
    getString(R.string.timber_log_format),
    super.createStackElementTag(element),
    element.lineNumber,
)

tag("okHttp") 메서드 호출하는 부분과 위 코드 블럭 중 하나는 무시될 거 같아

@@ -35,4 +40,6 @@ dependencies {
implementation(libs.okhttp.logging.interceptor)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.serialization.converter)
implementation(libs.timber)
Copy link
Member

Choose a reason for hiding this comment

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

아까 PR에 feature plugin 에 timber 넣은것 같은데 android library plugin 에 timber 넣고 기존 feature plugin 에 timber 지우면 이 디펜던시는 없어도 될것같아ㅏ@@@

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반영했습니다~

Copy link
Member

@youlalala youlalala left a comment

Choose a reason for hiding this comment

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

GOOOD!

@2taezeat 2taezeat merged commit 3d56964 into develop Nov 15, 2023
1 check passed
@2taezeat 2taezeat deleted the android/feature/timber branch November 18, 2023 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android android 🧦 chore Chore ✨ feat 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

timber 라이브러리 적용
3 participants