Skip to content

Commit 1091432

Browse files
committed
Remove okhttp level from public enum and add docs
1 parent 05114d6 commit 1091432

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/api/logging/HttpLoggingLevel.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@
1515
*/
1616
package io.getstream.feeds.android.client.api.logging
1717

18-
import okhttp3.logging.HttpLoggingInterceptor
18+
/**
19+
* Represents the logging levels for HTTP requests and responses.
20+
* - None: No logging.
21+
* - Basic: Logs request and response lines.
22+
* - Headers: Logs request and response lines along with their respective headers.
23+
* - Body: Logs request and response lines, headers, and bodies (if present).
24+
*/
25+
public enum class HttpLoggingLevel {
26+
/** No logging. */
27+
None,
28+
29+
/** Logs request and response lines. */
30+
Basic,
31+
32+
/** Logs request and response lines along with their respective headers. */
33+
Headers,
1934

20-
public enum class HttpLoggingLevel(internal val okhttp: HttpLoggingInterceptor.Level) {
21-
None(HttpLoggingInterceptor.Level.NONE),
22-
Basic(HttpLoggingInterceptor.Level.BASIC),
23-
Headers(HttpLoggingInterceptor.Level.HEADERS),
24-
Body(HttpLoggingInterceptor.Level.BODY),
35+
/** Logs request and response lines, headers, and bodies (if present). */
36+
Body,
2537
}

stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/logging/LoggingFactory.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,13 @@ internal fun createLoggingInterceptor(
3030
): Interceptor {
3131
val logger = provider.taggedLogger("FeedHTTP")
3232

33-
return HttpLoggingInterceptor(logger = { logger.i { it } }).setLevel(level.okhttp)
33+
return HttpLoggingInterceptor(logger = { logger.i { it } }).setLevel(level.toOkHttpLevel())
3434
}
35+
36+
private fun HttpLoggingLevel.toOkHttpLevel(): HttpLoggingInterceptor.Level =
37+
when (this) {
38+
HttpLoggingLevel.None -> HttpLoggingInterceptor.Level.NONE
39+
HttpLoggingLevel.Basic -> HttpLoggingInterceptor.Level.BASIC
40+
HttpLoggingLevel.Headers -> HttpLoggingInterceptor.Level.HEADERS
41+
HttpLoggingLevel.Body -> HttpLoggingInterceptor.Level.BODY
42+
}

0 commit comments

Comments
 (0)