From bb77eb305dbb87a50eda3bc60ea5012cacff7918 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Tue, 17 Apr 2018 19:32:31 +0200 Subject: [PATCH] Add Timber library for logging The idea is to add a Tree that can save the log to a file which can be enabled from the settings. --- android_app/app/build.gradle | 3 ++ android_app/app/src/main/AndroidManifest.xml | 1 + .../health/openscale/core/Application.java | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 android_app/app/src/main/java/com/health/openscale/core/Application.java diff --git a/android_app/app/build.gradle b/android_app/app/build.gradle index 76719cad..253e1d7a 100644 --- a/android_app/app/build.gradle +++ b/android_app/app/build.gradle @@ -57,6 +57,9 @@ dependencies { annotationProcessor 'android.arch.persistence.room:compiler:1.0.0' androidTestImplementation 'android.arch.persistence.room:testing:1.0.0' + // Timber + implementation 'com.jakewharton.timber:timber:4.7.0' + // Local unit tests testImplementation 'junit:junit:4.12' diff --git a/android_app/app/src/main/AndroidManifest.xml b/android_app/app/src/main/AndroidManifest.xml index 28ba58a6..58ac47e6 100644 --- a/android_app/app/src/main/AndroidManifest.xml +++ b/android_app/app/src/main/AndroidManifest.xml @@ -15,6 +15,7 @@ android:allowBackup="true" android:icon="@drawable/ic_launcher_openscale" android:label="@string/app_name" + android:name=".core.Application" android:theme="@style/AppTheme_Light" > + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.health.openscale.core; + +import com.health.openscale.BuildConfig; + +import timber.log.Timber; + +public class Application extends android.app.Application { + + @Override + public void onCreate() { + super.onCreate(); + + if (BuildConfig.DEBUG) { + Timber.plant(new Timber.DebugTree()); + } + } +}