Skip to content

Commit 5eac725

Browse files
kxlv2000chenyanlann
authored andcommitted
优化 system.err.printlin 输出
issure Tencent#232
1 parent 4116e5e commit 5eac725

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractParser.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,24 @@
4848
public abstract class AbstractParser<T> implements Parser<T>, ParserCreator<T>, VerifierCreator<T>, SQLCreator {
4949
protected static final String TAG = "AbstractParser";
5050

51+
/**
52+
* 可以通过切换该变量来控制是否打印关键的接口请求内容。保守起见,该值默认为false。
53+
* 与 {@link Log#DEBUG} 任何一个为 true 都会打印关键的接口请求内容。
54+
*/
55+
public static boolean IS_PRINT_REQUEST_STRING_LOG = true;
56+
5157
/**
5258
* 打印大数据量日志的标识。线上环境比较敏感,可以通过切换该变量来控制异常栈抛出、错误日志打印。保守起见,该值默认为false。
5359
* 与 {@link Log#DEBUG} 任何一个为 true 都会打印关键的接口请求及响应信息。
5460
*/
55-
public static boolean IS_PRINT_BIG_LOG = false;
61+
public static boolean IS_PRINT_BIG_LOG = true;
62+
63+
/**
64+
* 可以通过切换该变量来控制是否打印关键的接口请求结束时间。保守起见,该值默认为false。
65+
* 与 {@link Log#DEBUG} 任何一个为 true 都会打印关键的接口请求结束时间。
66+
*/
67+
public static boolean IS_PRINT_REQUEST_ENDTIME_LOG = true;
68+
5669

5770
/**
5871
* method = null
@@ -400,16 +413,18 @@ public JSONObject parseResponse(JSONObject request) {
400413

401414
onClose();
402415

403-
System.err.println("\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n "
404-
+ TAG + ".DEBUG: " + requestMethod + "/parseResponse request = \n" + requestString + "\n\n");
405-
406-
if (Log.DEBUG || IS_PRINT_BIG_LOG || error != null) { // 日志仅存服务器,所以不太敏感,而且这些日志虽然量大但非常重要,对排查 bug 很关键
407-
System.err.println(TAG + ".DEBUG: " + requestMethod + "/parseResponse return response = \n" + JSON.toJSONString(requestObject) + "\n\n");
416+
//CS304 Issue link: https://github.com/Tencent/APIJSON/issues/232
417+
if (IS_PRINT_REQUEST_STRING_LOG||Log.DEBUG||error != null) {
418+
Log.sl("\n\n\n",'<',"");
419+
Log.fd(TAG , requestMethod + "/parseResponse request = \n" + requestString + "\n\n");
420+
}
421+
if (IS_PRINT_BIG_LOG||Log.DEBUG||error != null) { // 日志仅存服务器,所以不太敏感,而且这些日志虽然量大但非常重要,对排查 bug 很关键
422+
Log.fd(TAG,requestMethod + "/parseResponse return response = \n" + JSON.toJSONString(requestObject) + "\n\n");
423+
}
424+
if (IS_PRINT_REQUEST_ENDTIME_LOG||Log.DEBUG||error != null) {
425+
Log.fd(TAG , requestMethod + "/parseResponse endTime = " + endTime + "; duration = " + duration);
426+
Log.sl("",'>',"\n\n\n");
408427
}
409-
410-
System.err.println(TAG + ".DEBUG: " + requestMethod + "/parseResponse endTime = " + endTime + "; duration = " + duration
411-
+ "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n\n");
412-
413428
return res;
414429
}
415430

0 commit comments

Comments
 (0)