mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve LogFilter
This commit is contained in:
@@ -21,6 +21,8 @@ import java.sql.Types;
|
||||
|
||||
import com.alibaba.druid.filter.FilterChain;
|
||||
import com.alibaba.druid.filter.FilterEventAdapter;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.alibaba.druid.proxy.jdbc.CallableStatementProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
|
||||
@@ -578,5 +580,34 @@ public abstract class LogFilter extends FilterEventAdapter implements LogFilterM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataSource_releaseConnection(FilterChain chain, DruidPooledConnection conn) throws SQLException {
|
||||
long connectionId = -1;
|
||||
|
||||
if (conn.getConnectionHolder() != null) {
|
||||
ConnectionProxy connection = (ConnectionProxy) conn.getConnectionHolder().getConnection();
|
||||
connectionId = connection.getId();
|
||||
}
|
||||
|
||||
chain.dataSource_recycle(conn);
|
||||
|
||||
if (connectionCloseAfterLogEnable && isConnectionLogEnabled()) {
|
||||
connectionLog("{conn-" + connectionId + "} pool-recycle");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DruidPooledConnection dataSource_getConnection(FilterChain chain, DruidDataSource dataSource, long maxWaitMillis) throws SQLException {
|
||||
DruidPooledConnection conn = chain.dataSource_connect(dataSource, maxWaitMillis);
|
||||
|
||||
ConnectionProxy connection = (ConnectionProxy) conn.getConnectionHolder().getConnection();
|
||||
|
||||
if (connectionConnectAfterLogEnable && isConnectionLogEnabled()) {
|
||||
connectionLog("{conn-" + connection.getId() + "} pool-connect");
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user