Skip to content

Commit

Permalink
Update MapperProxy.java (alibaba#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 authored and wukong121 committed Aug 3, 2023
1 parent ce88418 commit 8409c25
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 8409c25

Please sign in to comment.