Bouquet is a java / android library that helps debugging RxJava2 by logging various data for Observables, Flowables, Singles, Maybes and Completables.
- For Android, only debuggable builds will be annotated and wrapped with the debug logic.
- For java, you might want to disable it in your build.gradle file on release builds.
The logged info include:
- Description of the method called
- Life cycle events from RxJava
- A summary of the result:
- count of items
- benchmark
- whether it is synchronous or asynchronous
- subscribing/observing scheduler and thread name
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.quanturium.bouquet:bouquet-plugin:1.3.1'
}
}
apply plugin: 'com.quanturium.bouquet'
// Enable or disable Bouquet. By default enabled=true
bouquet {
enabled true
}
Annotate any method returning an Observable, Flowable, Single, Maybe, Completable from RxJava2 with @RxLogger
@RxLogger
private static Observable<String> getObservableExample(String extra) {
return Observable.just("String 1", "String 2", "String 3", extra)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.newThread());
}
This will print out the following
or in Kotlin:
@RxLogger(SUMMARY)
fun getKotlinCompletableExample(): Completable {
return Completable.complete() // Useless, just for demo purposes
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.newThread())
}
You can change the scope of logs in order to log more or less info:
@RxLogger(LIFECYCLE)
Possible values:
enum RxLogger.Scope {ALL, SOURCE, LIFECYCLE, SUMMARY, NONE}
Enable/disable Bouquet at runtime:
Bouquet.setEnabled(false);
By default bouquet uses AndroidLogger() for Android, JavaLogger() for java. You can customize the logger at runtime:
Bouquet.setLogger((tag, message) -> {
Timber.i(message);
});
In order to run the sample with the plugin code, the plugin must be pushed to your local maven repository. The sample project will then pick up the local version of the plugin and use it.
./gradlew install
install the plugin in your local repo./gradlew cleanSampleAndroid
clean the android sample./gradlew installSampleAndroid
install the android sample on your device./gradlew cleanSampleJava
clean the java sample./gradlew runSampleJava
run the java sample
- Jake Wharton for the Hugo plugin this library was inspired by.
- Fernando Cejas for creating the frodo / frodo2 plugin. This library was inspired by frodo and made compatible for RxJava2
Copyright (c) 2018 Arnaud Frugier
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.