Skip to content

Commit

Permalink
优化 system.err.printlin 输出
Browse files Browse the repository at this point in the history
  • Loading branch information
kxlv2000 authored and chenyanlann committed Aug 1, 2021
1 parent 4116e5e commit 5eac725
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions APIJSONORM/src/main/java/apijson/orm/AbstractParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,24 @@
public abstract class AbstractParser<T> implements Parser<T>, ParserCreator<T>, VerifierCreator<T>, SQLCreator {
protected static final String TAG = "AbstractParser";

/**
* 可以通过切换该变量来控制是否打印关键的接口请求内容。保守起见,该值默认为false。
* 与 {@link Log#DEBUG} 任何一个为 true 都会打印关键的接口请求内容。
*/
public static boolean IS_PRINT_REQUEST_STRING_LOG = true;

/**
* 打印大数据量日志的标识。线上环境比较敏感,可以通过切换该变量来控制异常栈抛出、错误日志打印。保守起见,该值默认为false。
* 与 {@link Log#DEBUG} 任何一个为 true 都会打印关键的接口请求及响应信息。
*/
public static boolean IS_PRINT_BIG_LOG = false;
public static boolean IS_PRINT_BIG_LOG = true;

/**
* 可以通过切换该变量来控制是否打印关键的接口请求结束时间。保守起见,该值默认为false。
* 与 {@link Log#DEBUG} 任何一个为 true 都会打印关键的接口请求结束时间。
*/
public static boolean IS_PRINT_REQUEST_ENDTIME_LOG = true;


/**
* method = null
Expand Down Expand Up @@ -400,16 +413,18 @@ public JSONObject parseResponse(JSONObject request) {

onClose();

System.err.println("\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n "
+ TAG + ".DEBUG: " + requestMethod + "/parseResponse request = \n" + requestString + "\n\n");

if (Log.DEBUG || IS_PRINT_BIG_LOG || error != null) { // 日志仅存服务器,所以不太敏感,而且这些日志虽然量大但非常重要,对排查 bug 很关键
System.err.println(TAG + ".DEBUG: " + requestMethod + "/parseResponse return response = \n" + JSON.toJSONString(requestObject) + "\n\n");
//CS304 Issue link: https://github.com/Tencent/APIJSON/issues/232
if (IS_PRINT_REQUEST_STRING_LOG||Log.DEBUG||error != null) {
Log.sl("\n\n\n",'<',"");
Log.fd(TAG , requestMethod + "/parseResponse request = \n" + requestString + "\n\n");
}
if (IS_PRINT_BIG_LOG||Log.DEBUG||error != null) { // 日志仅存服务器,所以不太敏感,而且这些日志虽然量大但非常重要,对排查 bug 很关键
Log.fd(TAG,requestMethod + "/parseResponse return response = \n" + JSON.toJSONString(requestObject) + "\n\n");
}
if (IS_PRINT_REQUEST_ENDTIME_LOG||Log.DEBUG||error != null) {
Log.fd(TAG , requestMethod + "/parseResponse endTime = " + endTime + "; duration = " + duration);
Log.sl("",'>',"\n\n\n");
}

System.err.println(TAG + ".DEBUG: " + requestMethod + "/parseResponse endTime = " + endTime + "; duration = " + duration
+ "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n\n");

return res;
}

Expand Down

0 comments on commit 5eac725

Please sign in to comment.