Skip to content

Commit

Permalink
修复了少设置offset method出现的bug,支持了log的包装类
Browse files Browse the repository at this point in the history
  • Loading branch information
Kale committed Dec 9, 2015
1 parent 35e9854 commit ad300f3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':logger')
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':logger')
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ protected void onCreate(Bundle savedInstanceState) {
.hideThreadInfo() // default shown
.setMethodCount(2) // default 2
.setMethodOffset(0) // default 0
.setMethodOffset(1)
.setLogLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE); // show log in debug state

printNormalLog();
printPretty();
}
Expand Down Expand Up @@ -86,9 +87,7 @@ void test2() {
}

public static class User {

private String name;

private String sex;

User(String name, String sex) {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/orhanobut/loggersample/P.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.orhanobut.loggersample;

import com.orhanobut.logger.Logger;

/**
* @author Jack Tony
* @date 2015/12/9
*/
public class P {

public static void print() {
Logger.d("dddd");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private void logChunk(int logType, String tag, String chunk) {

private String getCurrentClassName() {
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
int offset = getStackOffset(trace);
int offset = getStackOffset(trace) + settings.getMethodOffset();
StackTraceElement thisMethodStack = (new Exception()).getStackTrace()[offset - 1];
String result = thisMethodStack.getClassName();
int lastIndex = result.lastIndexOf(".");
Expand Down

0 comments on commit ad300f3

Please sign in to comment.