Skip to content

Commit

Permalink
Always add log interceptor to OkHttpClient
Browse files Browse the repository at this point in the history
In case debug logs are disabled then the KotlinLogging log level will be set to level > debug and thus, these logs won't get logged
  • Loading branch information
schroda committed Jul 28, 2023
1 parent 609347c commit 7d1e6e2
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ class NetworkHelper(context: Context) {
.callTimeout(2, TimeUnit.MINUTES)
.addInterceptor(UserAgentInterceptor())

if (serverConfig.debugLogsEnabled.value) {
val httpLoggingInterceptor = HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
val logger = KotlinLogging.logger { }
val httpLoggingInterceptor = HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
val logger = KotlinLogging.logger { }

override fun log(message: String) {
logger.debug { message }
}
}).apply {
level = HttpLoggingInterceptor.Level.BASIC
override fun log(message: String) {
logger.debug { message }
}
builder.addInterceptor(httpLoggingInterceptor)
}).apply {
level = HttpLoggingInterceptor.Level.BASIC
}
builder.addInterceptor(httpLoggingInterceptor)

// when (preferences.dohProvider()) {
// PREF_DOH_CLOUDFLARE -> builder.dohCloudflare()
Expand Down

0 comments on commit 7d1e6e2

Please sign in to comment.