wisdomisite-java/src/main/java/com/zhgd/config/StdOutImplCustom.java

57 lines
1.2 KiB
Java
Raw Normal View History

2024-06-01 14:37:49 +08:00
package com.zhgd.config;
2024-06-06 21:13:17 +08:00
import com.zhgd.xmgl.util.LogMdcUtil;
2024-06-01 14:37:49 +08:00
import org.apache.ibatis.logging.Log;
public class StdOutImplCustom implements Log {
public StdOutImplCustom(String clazz) {
// Do Nothing
}
@Override
public boolean isDebugEnabled() {
2024-06-06 21:13:17 +08:00
return LogMdcUtil.isPrint();
2024-06-01 14:37:49 +08:00
}
@Override
public boolean isTraceEnabled() {
2024-06-06 21:13:17 +08:00
return LogMdcUtil.isPrint();
2024-06-01 14:37:49 +08:00
}
@Override
public void error(String s, Throwable e) {
System.err.println(s);
e.printStackTrace(System.err);
}
@Override
public void error(String s) {
System.err.println(s);
}
@Override
public void debug(String s) {
2024-06-06 21:13:17 +08:00
if (LogMdcUtil.isPrint()) {
2024-06-06 23:21:11 +08:00
System.out.println(processSql(s));
2024-06-01 14:37:49 +08:00
}
}
@Override
public void trace(String s) {
2024-06-06 21:13:17 +08:00
if (LogMdcUtil.isPrint()) {
2024-06-06 23:21:11 +08:00
System.out.println(processSql(s));
2024-06-01 14:37:49 +08:00
}
}
@Override
public void warn(String s) {
System.out.println(s);
}
2024-06-06 23:21:11 +08:00
// 自定义方法处理SQL语句去除换行符
private String processSql(String sql) {
return sql.replaceAll("(?m)^[ \t]*\r?\n", "");
}
2024-06-01 14:37:49 +08:00
}