Skip to content

Commit

Permalink
Update MapperProxy.java (#10487)
Browse files Browse the repository at this point in the history
* Update MapperProxy.java

fix:代理类打印日志错误

* Update MapperProxy.java

fix:代理类打印日志错误

* 规范格式

* Update MapperProxy.java

reformat code

* Update MapperProxy.java

reformat code
  • Loading branch information
scwlkq committed May 17, 2023
1 parent 70b9649 commit ee30e35
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.plugin.datasource.mapper.Mapper;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -79,8 +80,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl

String className = mapper.getClass().getSimpleName();
String methodName = method.getName();
String sql = invoke.toString();

String sql;
if (invoke instanceof MapperResult) {
sql = ((MapperResult) invoke).getSql();
} else {
sql = invoke.toString();
}
LOGGER.info("[{}] METHOD : {}, SQL : {}, ARGS : {}", className, methodName, sql, JacksonUtils.toJson(args));
return invoke;
}
Expand Down

0 comments on commit ee30e35

Please sign in to comment.