|
48 | 48 | public abstract class AbstractParser<T> implements Parser<T>, ParserCreator<T>, VerifierCreator<T>, SQLCreator {
|
49 | 49 | protected static final String TAG = "AbstractParser";
|
50 | 50 |
|
| 51 | + /** |
| 52 | + * 打印大数据量日志的标识。线上环境比较敏感,可以通过切换该变量来控制异常栈抛出、错误日志打印。保守起见,该值默认为false。 |
| 53 | + * 与 {@link Log#DEBUG} 任何一个为 true 都会打印关键的接口请求及响应信息。 |
| 54 | + */ |
| 55 | + public static boolean IS_PRINT_BIG_LOG = false; |
51 | 56 |
|
52 | 57 | /**
|
53 | 58 | * method = null
|
@@ -301,9 +306,6 @@ public JSONObject parseResponse(String request) {
|
301 | 306 |
|
302 | 307 | private int queryDepth;
|
303 | 308 |
|
304 |
| - // 打印异常日志的标识。线上环境比较敏感,可以通过切换该变量来控制异常栈抛出、错误日志打印。保守起见,该值默认为false。 |
305 |
| - public static boolean isPrintErrorLog = false; |
306 |
| - |
307 | 309 | /**解析请求json并获取对应结果
|
308 | 310 | * @param request
|
309 | 311 | * @return requestObject
|
@@ -386,30 +388,27 @@ public JSONObject parseResponse(JSONObject request) {
|
386 | 388 | long endTime = System.currentTimeMillis();
|
387 | 389 | long duration = endTime - startTime;
|
388 | 390 |
|
389 |
| - if (isPrintErrorLog) { //用 | 替代 /,避免 APIJSON ORM,APIAuto 等解析路径错误 |
| 391 | + if (Log.DEBUG) { |
390 | 392 | requestObject.put("sql:generate|cache|execute|maxExecute", getSQLExecutor().getGeneratedSQLCount() + "|" + getSQLExecutor().getCachedSQLCount() + "|" + getSQLExecutor().getExecutedSQLCount() + "|" + getMaxSQLCount());
|
391 | 393 | requestObject.put("depth:count|max", queryDepth + "|" + getMaxQueryDepth());
|
392 | 394 | requestObject.put("time:start|duration|end", startTime + "|" + duration + "|" + endTime);
|
393 | 395 | if (error != null) {
|
394 |
| - Log.d(TAG, String.format("onObjectParse error, error is %s", error.getMessage())); |
395 | 396 | requestObject.put("throw", error.getClass().getName());
|
396 | 397 | requestObject.put("trace", error.getStackTrace());
|
397 | 398 | }
|
398 | 399 | }
|
399 | 400 |
|
400 | 401 | onClose();
|
401 | 402 |
|
402 |
| - //会不会导致原来的session = null? session = null; |
403 |
| - |
404 |
| - if (isPrintErrorLog) { |
405 |
| - Log.d(TAG, "\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n " |
406 |
| - + requestMethod + "/parseResponse request = \n" + requestString + "\n\n"); |
407 |
| - |
408 |
| - Log.d(TAG, "parseResponse return response = \n" + JSON.toJSONString(requestObject) |
409 |
| - + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n\n"); |
| 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"); |
410 | 408 | }
|
411 |
| - Log.d(TAG, "parseResponse endTime = " + endTime + "; duration = " + duration |
412 |
| - + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n"); |
| 409 | + |
| 410 | + System.err.println(TAG + ".DEBUG: " + requestMethod + "/parseResponse endTime = " + endTime + "; duration = " + duration |
| 411 | + + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n\n"); |
413 | 412 |
|
414 | 413 | return res;
|
415 | 414 | }
|
|
0 commit comments