Skip to content

Commit

Permalink
- update project
Browse files Browse the repository at this point in the history
- remove dependencies to SLF4J
  • Loading branch information
Major Laszlo committed Aug 25, 2016
1 parent 57ebbad commit a131ff3
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 69 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unified Logger

A logging framework that wraps around SLF4J and Crashlytics (Fabric.io)
A logging framework that wraps around Timber and Crashlytics (Fabric.io)

## Download
* ###If you are including including the library off jCenter:
Expand Down Expand Up @@ -32,9 +32,7 @@ compile name: 'unified-logger', ext: 'aar'
```
* Add the dependencies of the library:
```
compile 'org.slf4j:slf4j-api:1.7.10'
compile 'com.github.tony19:logback-android-core:1.1.1-3'
compile 'com.github.tony19:logback-android-classic:1.1.1-3'
compile 'com.jakewharton.timber:timber:4.3.0'
```


Expand All @@ -44,7 +42,6 @@ compile name: 'unified-logger', ext: 'aar'
* WRITE_EXTERNAL_STORAGE would be needed if you wanted to write logs on the SD card, like the demo application does.

## Configuration
* You need to configure the SLF4J with a configuration file **Logback.xml** that goes in the /assets folder. An example configuration file is provided in the sample project, and more detailed explanation is provided at [logback-android]
* Fabric.io has to be added to the project, as every project must acquire it's own unique API key for Crashlytics to work. This can be done easily via the [Fabric.io] Android Studio plugin.

## Usage
Expand All @@ -59,8 +56,7 @@ private static final UnifiedLogger LOG = UnifiedLogger.getUnifiedLogger(YourClas
LOG.d(TAG, "your message", true);
```

This will log a message at the DEBUG priority level into both SLF4J and Crashlytics. Logs that were passed into Crashlytics (with true) will accompany the crash report that you get on the site, if there's been a crash.
This will log a message at the DEBUG priority level into both LogCat and Crashlytics. Logs that were passed into Crashlytics (with true) will accompany the crash report that you get on the site, if there's been a crash.


[logback-android]:https://github.com/tony19/logback-android
[Fabric.io]:https://get.fabric.io/
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ repositories {
}

android {
compileSdkVersion 22
buildToolsVersion "22"
compileSdkVersion 24
buildToolsVersion "24.0.1"

defaultConfig {
applicationId "com.levi9.android.unified_logger_demo"
minSdkVersion 15
targetSdkVersion 22
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
Expand All @@ -41,9 +41,9 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
// compile('com.crashlytics.sdk.android:crashlytics:2.2.1@aar') {
// transitive = true;
// }
compile 'com.android.support:appcompat-v7:24.2.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.1@aar') {
transitive = true;
}
compile project(':unified-logger')
}
5 changes: 1 addition & 4 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class ch.qos.** { *; }
-keep class org.slf4j.** { *; }
-keepattributes *Annotation*
-dontwarn ch.qos.logback.core.net.*
-keepattributes *Annotation*
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
import com.crashlytics.android.Crashlytics;
import com.levi9.android.unified_logger.UnifiedLogger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import io.fabric.sdk.android.Fabric;


public class UnifiedLoggerDemo extends ActionBarActivity {
public class UnifiedLoggerDemo extends AppCompatActivity {

private static final UnifiedLogger LOG = UnifiedLogger.getUnifiedLogger(UnifiedLoggerDemo.class);

Expand All @@ -29,8 +25,8 @@ protected void onCreate(Bundle savedInstanceState) {
//You can use this method to disable crashlytics in a specific flavor. Careful, BuildConfig.DEBUG is not always set correctly.
//Disabled so we can remove secrets in the public
//will instant crash without this
//Crashlytics crashlytics = new Crashlytics.Builder().disabled(false).build();
//Fabric.with(this, crashlytics);
Crashlytics crashlytics = new Crashlytics.Builder().disabled(false).build();
Fabric.with(this, crashlytics);

setContentView(R.layout.activity_unified_logger_demo);
LOG.d(TAG, "MSG", true);
Expand Down Expand Up @@ -78,7 +74,7 @@ public void crash(View v) {
try {
throw new ArithmeticException("panic!");
} catch (Exception ex) {
LOG.e(TAG, ex.toString(), true);
LOG.e(TAG, ex.getMessage(), true, ex);
throw new RuntimeException("crash");
}
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Thu Aug 25 10:18:20 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
16 changes: 6 additions & 10 deletions unified-logger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
id "com.jfrog.bintray" version "1.1"
}

version = "0.2"
version = "0.3"

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
Expand All @@ -24,12 +24,12 @@ repositories {
}

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 24
buildToolsVersion "24.0.1"

defaultConfig {
minSdkVersion 14
targetSdkVersion 22
targetSdkVersion 24
versionCode 1
versionName version
}
Expand Down Expand Up @@ -81,9 +81,7 @@ install {
}

dependencies {
compile 'org.slf4j:slf4j-api:1.7.10'
compile 'com.github.tony19:logback-android-core:1.1.1-3'
compile 'com.github.tony19:logback-android-classic:1.1.1-3'
compile 'com.jakewharton.timber:timber:4.3.0'
}

task sourcesJar(type: Jar) {
Expand Down Expand Up @@ -124,9 +122,7 @@ bintray {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.slf4j:slf4j-api:1.7.10'
compile 'com.github.tony19:logback-android-core:1.1.1-3'
compile 'com.github.tony19:logback-android-classic:1.1.1-3'
compile 'com.jakewharton.timber:timber:4.3.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.1@aar') {
transitive = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.levi9.android.unified_logger;

import android.util.Log;

import timber.log.Timber;

/**
* Created by l.major on 25/08/16.
*/

public class LogCatTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
Log.println(priority, tag, message);
}

}
Loading

0 comments on commit a131ff3

Please sign in to comment.