EventBus logs using Timber

This commit is contained in:
Benoit Marty 2020-04-24 11:34:16 +02:00
parent 20b3c33fb0
commit 270bed5013
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2020 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.matrix.android.internal.eventbus
import org.greenrobot.eventbus.Logger
import timber.log.Timber
import java.util.logging.Level
class EventBusTimberLogger : Logger {
override fun log(level: Level, msg: String) {
Timber.d(msg)
}
override fun log(level: Level, msg: String, th: Throwable) {
Timber.e(th, msg)
}
}

View File

@ -49,6 +49,7 @@ import im.vector.matrix.android.internal.di.SessionId
import im.vector.matrix.android.internal.di.Unauthenticated
import im.vector.matrix.android.internal.di.UserId
import im.vector.matrix.android.internal.di.UserMd5
import im.vector.matrix.android.internal.eventbus.EventBusTimberLogger
import im.vector.matrix.android.internal.network.AccessTokenInterceptor
import im.vector.matrix.android.internal.network.DefaultNetworkConnectivityChecker
import im.vector.matrix.android.internal.network.FallbackNetworkCallbackStrategy
@ -205,7 +206,10 @@ internal abstract class SessionModule {
@Provides
@SessionScope
fun providesEventBus(): EventBus {
return EventBus.builder().build()
return EventBus
.builder()
.logger(EventBusTimberLogger())
.build()
}
@JvmStatic