61 lines
1.2 KiB
Java
61 lines
1.2 KiB
Java
package com.zhgd.config;
|
||
|
||
import com.zhgd.xmgl.util.LogMdcUtil;
|
||
import org.apache.ibatis.logging.Log;
|
||
|
||
public class StdOutImplCustom implements Log {
|
||
|
||
public StdOutImplCustom(String clazz) {
|
||
// Do Nothing
|
||
}
|
||
|
||
@Override
|
||
public boolean isDebugEnabled() {
|
||
return LogMdcUtil.isPrint();
|
||
}
|
||
|
||
@Override
|
||
public boolean isTraceEnabled() {
|
||
return LogMdcUtil.isPrint();
|
||
}
|
||
|
||
@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) {
|
||
if (LogMdcUtil.isPrint()) {
|
||
System.out.println(processSql(s));
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void trace(String s) {
|
||
if (LogMdcUtil.isPrint()) {
|
||
System.out.println(processSql(s));
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void warn(String s) {
|
||
System.out.println(s);
|
||
}
|
||
|
||
/**
|
||
* 自定义方法处理SQL语句,去除换行符
|
||
* @param sql
|
||
* @return
|
||
*/
|
||
private String processSql(String sql) {
|
||
return sql.replaceAll("(?m)^[ \t]*\r?\n", "");
|
||
}
|
||
}
|