Skip to content

Commit 0cab34c

Browse files
committed
see 04/02 log
1 parent 2a2887c commit 0cab34c

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ android {
4848

4949
dependencies {
5050
implementation fileTree(include: ['*.jar'], dir: 'libs')
51-
// implementation project(':utilcode')
51+
implementation project(':utilcode')
5252
implementation project(':subutil')
5353
implementation "com.android.support:appcompat-v7:$support_version"
5454
implementation "com.android.support:design:$support_version"
5555
implementation 'com.r0adkll:slidableactivity:2.0.5'
5656
// LeakCanary
5757
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
5858
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
59-
implementation 'com.blankj:utilcode:1.13.6'
59+
// implementation 'com.blankj:utilcode:1.13.6'
6060
}
6161

6262

app/src/main/java/com/blankj/androidutilcode/UtilsApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void initLog() {
6464
.setBorderSwitch(true)// 输出日志是否带边框开关,默认开
6565
.setConsoleFilter(LogUtils.V)// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose
6666
.setFileFilter(LogUtils.V)// log 文件过滤器,和 logcat 过滤器同理,默认 Verbose
67-
.setStackDeep(1);// log 栈深度,默认为 1
67+
.setStackDeep(10);// log 栈深度,默认为 1
6868
new Thread(new Runnable() {
6969
@Override
7070
public void run() {

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.0.1'
8+
classpath 'com.android.tools.build:gradle:3.1.0'
99
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
1010
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
1111

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Feb 27 13:02:08 CST 2017
1+
#Sat Mar 31 15:05:28 CST 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

utilcode/src/main/java/com/blankj/utilcode/util/LogUtils.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -224,31 +224,17 @@ private static TagHead processTagAndHead(String tag) {
224224
} else {
225225
final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
226226
StackTraceElement targetElement = stackTrace[3];
227-
String fileName = targetElement.getFileName();
228-
String className;
229-
// If name of file is null, should add
230-
// "-keepattributes SourceFile,LineNumberTable" in proguard file.
231-
if (fileName == null) {
232-
className = targetElement.getClassName();
233-
String[] classNameInfo = className.split("\\.");
234-
if (classNameInfo.length > 0) {
235-
className = classNameInfo[classNameInfo.length - 1];
236-
}
237-
int index = className.indexOf('$');
238-
if (index != -1) {
239-
className = className.substring(0, index);
240-
}
241-
fileName = className + ".java";
242-
} else {
227+
final String fileName = getFileName(targetElement);
228+
if (sTagIsSpace && isSpace(tag)) {
243229
int index = fileName.indexOf('.');// Use proguard may not find '.'.
244-
className = index == -1 ? fileName : fileName.substring(0, index);
230+
tag = index == -1 ? fileName : fileName.substring(0, index);
245231
}
246-
if (sTagIsSpace) tag = isSpace(tag) ? className : tag;
247232
if (sLogHeadSwitch) {
248233
String tName = Thread.currentThread().getName();
249234
final String head = new Formatter()
250-
.format("%s, %s(%s:%d)",
235+
.format("%s, %s.%s(%s:%d)",
251236
tName,
237+
targetElement.getClassName(),
252238
targetElement.getMethodName(),
253239
fileName,
254240
targetElement.getLineNumber())
@@ -265,10 +251,11 @@ private static TagHead processTagAndHead(String tag) {
265251
for (int i = 1, len = consoleHead.length; i < len; ++i) {
266252
targetElement = stackTrace[i + 3];
267253
consoleHead[i] = new Formatter()
268-
.format("%s%s(%s:%d)",
254+
.format("%s%s.%s(%s:%d)",
269255
space,
256+
targetElement.getClassName(),
270257
targetElement.getMethodName(),
271-
targetElement.getFileName(),
258+
getFileName(targetElement),
272259
targetElement.getLineNumber())
273260
.toString();
274261
}
@@ -279,6 +266,23 @@ private static TagHead processTagAndHead(String tag) {
279266
return new TagHead(tag, null, ": ");
280267
}
281268

269+
private static String getFileName(final StackTraceElement targetElement) {
270+
String fileName = targetElement.getFileName();
271+
if (fileName != null) return fileName;
272+
// If name of file is null, should add
273+
// "-keepattributes SourceFile,LineNumberTable" in proguard file.
274+
String className = targetElement.getClassName();
275+
String[] classNameInfo = className.split("\\.");
276+
if (classNameInfo.length > 0) {
277+
className = classNameInfo[classNameInfo.length - 1];
278+
}
279+
int index = className.indexOf('$');
280+
if (index != -1) {
281+
className = className.substring(0, index);
282+
}
283+
return className + ".java";
284+
}
285+
282286
private static String processBody(final int type, final Object... contents) {
283287
String body = NULL;
284288
if (contents != null) {

0 commit comments

Comments
 (0)