|
@@ -1,34 +1,34 @@
|
|
|
-package com.ydtech.utils;
|
|
|
|
|
-
|
|
|
|
|
-import com.p6spy.engine.common.P6Util;
|
|
|
|
|
-import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
|
|
|
|
|
-
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
-
|
|
|
|
|
-public class P6SpyLogger implements MessageFormattingStrategy {
|
|
|
|
|
|
|
+//package com.ydtech.utils;
|
|
|
|
|
+//
|
|
|
|
|
+//import com.p6spy.engine.common.P6Util;
|
|
|
|
|
+//import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
|
|
|
|
|
+//
|
|
|
|
|
+//import java.text.SimpleDateFormat;
|
|
|
|
|
+//
|
|
|
|
|
+//public class P6SpyLogger implements MessageFormattingStrategy {
|
|
|
|
|
+//// private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
|
|
|
|
+////
|
|
|
|
|
+//// @Override
|
|
|
|
|
+//// public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
|
|
|
|
|
+//// return StringUtils.isNotBlank(sql) ? DateUtil.formatFullTime(LocalDateTime.now(), DateUtil.FULL_TIME_SPLIT_PATTERN)
|
|
|
|
|
+//// + " | 耗时 " + elapsed + " ms | SQL 语句:" + StringUtils.LF + sql.replaceAll("[\\s]+", StringUtils.SPACE) + ";" : StringUtils.EMPTY;
|
|
|
|
|
+//// }
|
|
|
|
|
+//
|
|
|
// private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
|
// private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
|
|
//
|
|
//
|
|
|
// @Override
|
|
// @Override
|
|
|
// public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
|
|
// public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
|
|
|
-// return StringUtils.isNotBlank(sql) ? DateUtil.formatFullTime(LocalDateTime.now(), DateUtil.FULL_TIME_SPLIT_PATTERN)
|
|
|
|
|
-// + " | 耗时 " + elapsed + " ms | SQL 语句:" + StringUtils.LF + sql.replaceAll("[\\s]+", StringUtils.SPACE) + ";" : StringUtils.EMPTY;
|
|
|
|
|
|
|
+// StringBuilder sb = new StringBuilder();
|
|
|
|
|
+// sb
|
|
|
|
|
+// .append("=====================================================\n")
|
|
|
|
|
+// .append("连接id:").append(connectionId).append("\n")
|
|
|
|
|
+// .append("当前时间:").append(now).append("\n")
|
|
|
|
|
+// .append("类别:").append(category).append("\n")
|
|
|
|
|
+// .append("花费时间:").append(elapsed).append(" ms\n")
|
|
|
|
|
+//// .append("url:").append(url).append("\n")
|
|
|
|
|
+// .append("预编译sql:").append(P6Util.singleLine(prepared)).append("\n")
|
|
|
|
|
+// .append("最终执行的sql:").append(P6Util.singleLine(sql))
|
|
|
|
|
+// .append("\n=====================================================\n");
|
|
|
|
|
+// return sb.toString();
|
|
|
// }
|
|
// }
|
|
|
-
|
|
|
|
|
- private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
|
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
|
|
- sb
|
|
|
|
|
- .append("=====================================================\n")
|
|
|
|
|
- .append("连接id:").append(connectionId).append("\n")
|
|
|
|
|
- .append("当前时间:").append(now).append("\n")
|
|
|
|
|
- .append("类别:").append(category).append("\n")
|
|
|
|
|
- .append("花费时间:").append(elapsed).append(" ms\n")
|
|
|
|
|
-// .append("url:").append(url).append("\n")
|
|
|
|
|
- .append("预编译sql:").append(P6Util.singleLine(prepared)).append("\n")
|
|
|
|
|
- .append("最终执行的sql:").append(P6Util.singleLine(sql))
|
|
|
|
|
- .append("\n=====================================================\n");
|
|
|
|
|
- return sb.toString();
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//}
|