Some trees for Timber lib
build.gradle
repositories {
jcenter()
maven { url "https://dl.bintray.com/bastienpaulfr/maven" }
}
dependencies {
//Treessence does not include Timber
implementation 'com.jakewharton.timber:timber:4.6.0'
implementation 'fr.bipi.treessence:treessence:0.2.0'
}
- Checkout Timber
- Add any trees you like
An implementation of Timber.Tree
which throws Error
when priority of
log is exceeded the limit. Useful for development or test environment.
// Will throw an error if Timber.e() is used
Timber.plant(new ThrowErrorTree(Log.ERROR));
An implementation of Timber.Tree
which logs into System.out
Timber.plant(new SystemLogTree());
An implementation of Timber.Tree
which sends log into a circular file.
java.util.logging.Logger
is used for logging
Tree t = new FileLoggerTree.Builder()
.withFileName("file%g.log")
.withDirName("my/dir")
.withSizeLimit(20000)
.withFileLimit(3)
.withMinPriority(Log.DEBUG)
.appendToFile(true)
.build();
Timber.plant(t);
An implementation of Timber.Tree
which stores breadcrumb to Sentry instance. Breadcrumbs are then sent with an event.
You need to add sentry dependency to use this tree.
Timber.plant(new SentryBreadcrumbTree(Log.DEBUG));
An implementation of Timber.Tree
which sends Sentry events. It is useful for sending errors or logs that are not coming so often.
Otherwise your sentry instance will be flooded !
You need to add sentry dependency to use this tree.
Timber.plant(new SentryEventTree(Log.ERROR));
You can also add a filter for SentryEvent
// This will send an event to Sentry only if priority exceeds "ERROR" level and class name starts with "Sentry"
TagFilter filter = new TagFilter("Sentry.*");
SentryEventTree tree = new SentryEventTree(Log.INFO).withFilter(TagFilter);
Timber.plant(tree);
An implementation of Timber.Tree
which sends log to Crashlytics.
You need to add crashlytics dependency to use this tree.
// Send log to crashlytics for logs starting from warning
Timber.plant(new CrashlyticsLogTree(Log.WARN));
Same as above but use Crashlytics.logException
instead of Crashlytics.log()
// Send log to crashlytics for logs starting from warning
Timber.plant(new CrashlyticsLogExceptionTree(Log.ERROR));
Copyright [2017] Bastien PAUL
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.