Skip to content

Commit ee09ded

Browse files
committed
fix:添加setHttpLogEvent方法,通过此方法可以拿到NetCore-Flow打印的所有日志
1 parent a770e79 commit ee09ded

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

FlowHttp/src/main/java/com/bhm/network/core/HttpOptions.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ class HttpOptions(private val builder: Builder) {
261261
}
262262

263263
fun build(): HttpOptions {
264-
return HttpOptions(this)
264+
val options = HttpOptions(this)
265+
JobManager.get().setHttpOptions(options)
266+
return options
265267
}
266268
}
267269

FlowHttp/src/main/java/com/bhm/network/core/interceptor/LoggingInterceptor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class LoggingInterceptor {
1717

1818
fun make(builder: HttpOptions): HttpLoggingInterceptor {
1919
return HttpLoggingInterceptor { message: String ->
20-
if (builder.isLogOutPut) {
20+
builder.httpLogEvent?.let {
2121
// 请求或者响应开始
2222
if (message.startsWith("--> POST") || message.startsWith("--> GET")) {
2323
mMessage.delete(0, mMessage.length)

app/src/main/java/com/bhm/sdk/demo/activity/MainActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import com.bhm.netcore.R
1616
import com.bhm.network.base.HttpLoadingDialog
1717
import com.bhm.network.core.HttpOptions
1818
import com.bhm.network.core.RequestManager
19+
import com.bhm.network.core.callback.HttpLogEvent
20+
import com.bhm.network.define.HttpLogLevel
1921
import com.bhm.network.define.ResultException
2022
import com.bhm.sdk.demo.adapter.MainUIAdapter
2123
import com.bhm.sdk.demo.entity.DoGetEntity
@@ -159,6 +161,13 @@ open class MainActivity : FragmentActivity() {
159161
.buildRequest<DoGetEntity>()
160162
.setHttpOptions(HttpOptions.create(this)
161163
.setLoadingDialog(HttpLoadingDialog())
164+
.setIsLogOutPut(false)
165+
.setHttpLogEvent(object : HttpLogEvent {
166+
override fun onLog(level: HttpLogLevel, tag: String, message: String?) {
167+
Log.e(tag, ("自定义输出日志:$message"))
168+
}
169+
170+
})
162171
.setDialogAttribute(
163172
isShowDialog = true,
164173
cancelable = true,

0 commit comments

Comments
 (0)