Skip to content
Some trees for Timber lib
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
gradle
treessence
.gitignore
.travis.yml
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Download Build Status

Treessence

Some trees for Timber lib

Set up

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'
}

Usage

  1. Checkout Timber
  2. Add any trees you like

Essences of tree

Console

ThrowErrorTree

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));

SystemLogTree

An implementation of Timber.Tree which logs into System.out

Timber.plant(new SystemLogTree());

File Logging

FileLoggerTree

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);

Crash reporting

SentryBreadcrumbTree

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));

SentryEventTree

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);

CrashlyticsLogTree

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));

CrashlyticsLogExceptionTree

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));

Licence

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.

You can’t perform that action at this time.