Skip to content

Commit

Permalink
重构了主体代码,引入了timber
Browse files Browse the repository at this point in the history
  • Loading branch information
kale committed Mar 26, 2016
1 parent 3bfcb29 commit f470fdb
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 305 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
applicationId "com.orhanobut.loggersample"
minSdkVersion 8
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
Expand Down
26 changes: 13 additions & 13 deletions app/src/main/java/com/orhanobut/loggersample/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.orhanobut.loggersample;

import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.Settings;

Expand All @@ -18,13 +17,9 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

Logger.initialize(
Settings.builder()
.isSmartTag(true)
.showThreadInfo(true)
.methodCount(1)
.methodOffset(0)
.logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE).build() // show log in debug state
);
Settings.getInstance()
.setMethodOffset(5)
.isShowThreadInfo(true));

levTest();
objTest();
Expand All @@ -36,18 +31,24 @@ protected void onCreate(Bundle savedInstanceState) {
private void levTest() {
Logger.v(null);
Logger.d("%s test", "kale"); // 多参数 可以解决release版本中字符拼接带来的性能消耗
String test = "abc %s def %s ghi";
String test = "abc %s def %s gh";
Logger.d(test);
Logger.d(test, "s");

Logger.t("tag", 3).i("logger with 3 method count");

//Logger.d(test, "s"); // Note:incorrect

Logger.t("Custom Tag").w("logger with custom tag");
try {
Class.forName("kale");
} catch (ClassNotFoundException e) {
Logger.e(e, "something happened"); // exception
}

Logger.d("first\nsecond\nthird");
test();
}

private void test() {
Logger.d("just test");
}

private void objTest() {
Expand Down Expand Up @@ -82,7 +83,6 @@ private void largeDataTest() {
Logger.d("No." + i);
}
}


///////////////////////////////////////////////////////////////////////////
// 内部类中打log测试
Expand Down
5 changes: 4 additions & 1 deletion logger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 8
minSdkVersion 15
targetSdkVersion 23
}

Expand All @@ -14,6 +14,9 @@ android {
dependencies {
provided 'com.android.support:support-annotations:23.2.1'
provided "org.projectlombok:lombok:1.12.6"

compile 'com.jakewharton.timber:timber:4.1.1'

testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile "org.robolectric:robolectric:3.0"
Expand Down
17 changes: 0 additions & 17 deletions logger/src/main/java/com/orhanobut/logger/LogLevel.java

This file was deleted.

Loading

0 comments on commit f470fdb

Please sign in to comment.