|
@@ -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 = sql.replaceFirst("\\?", "缺失");
|
|
|
}
|
|
|
+ //else {
|
|
|
+ // 如果都没有,说明SQL匹配不上,带上“缺失”方便找问题
|
|
|
+ // sql = sql.replaceFirst("\\?", "缺失");
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
}
|