|
@@ -45,8 +45,12 @@ public class MybatisProfilerPlugin implements Interceptor {
|
|
|
Object result = invocation.proceed();
|
|
|
long cost = System.currentTimeMillis() - start;
|
|
|
if (profilerProperties.isEnable() && cost > profilerProperties.getThreshold().toMillis()) {
|
|
|
- String sql = generateSql(invocation);
|
|
|
- log.info("Sql time cost: " + cost + "ms\n" + sql);
|
|
|
+ try {
|
|
|
+ String sql = generateSql(invocation);
|
|
|
+ log.info("Sql time cost: " + cost + "ms\n" + sql);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("Sql profiler error", e);
|
|
|
+ }
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -91,10 +95,11 @@ public class MybatisProfilerPlugin implements Interceptor {
|
|
|
} else if (boundSql.hasAdditionalParameter(propertyName)) {
|
|
|
Object obj = boundSql.getAdditionalParameter(propertyName);
|
|
|
sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(obj)));
|
|
|
- } else {
|
|
|
-
|
|
|
- sql = sql.replaceFirst("\\?", "缺失");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|