if config incorrect, log error

This commit is contained in:
wenshao
2012-08-07 07:51:15 +08:00
parent f458f31edb
commit 0c4b481c01
9 changed files with 127 additions and 3 deletions
@@ -72,7 +72,7 @@ import com.alibaba.druid.util.JdbcUtils;
*/
public class DruidDataSource extends DruidAbstractDataSource implements DruidDataSourceMBean, ManagedDataSource, Referenceable, Closeable, Cloneable, ConnectionPoolDataSource {
private final static Log LOG = LogFactory.getLog(DruidDataSource.class);
public final static Log LOG = LogFactory.getLog(DruidDataSource.class);
private static final long serialVersionUID = 1L;
@@ -288,7 +288,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
DataSourceProxyConfig config = DruidDriver.parseConfig(jdbcUrl, null);
this.driverClass = config.getRawDriverClassName();
LOG.error("error url : " + jdbcUrl + ", it should be : " + config.getRawUrl());
LOG.error("error url : '" + jdbcUrl + "', it should be : '" + config.getRawUrl() + "'");
this.jdbcUrl = config.getRawUrl();
if (this.name == null) {
@@ -7,6 +7,8 @@ public class JakartaCommonsLoggingImpl implements com.alibaba.druid.support.logg
private Log log;
private int errorCount;
public JakartaCommonsLoggingImpl(Class<?> clazz){
log = LogFactory.getLog(clazz);
}
@@ -17,10 +19,12 @@ public class JakartaCommonsLoggingImpl implements com.alibaba.druid.support.logg
public void error(String s, Throwable e) {
log.error(s, e);
errorCount++;
}
public void error(String s) {
log.error(s);
errorCount++;
}
public void debug(String s) {
@@ -40,4 +44,14 @@ public class JakartaCommonsLoggingImpl implements com.alibaba.druid.support.logg
log.warn(s, e);
}
public int getErrorCount() {
return errorCount;
}
@Override
public void resetStat() {
errorCount = 0;
}
}
@@ -6,6 +6,8 @@ import java.util.logging.Logger;
public class Jdk14LoggingImpl implements Log {
private Logger log;
private int errorCount;
public Jdk14LoggingImpl(Class<?> clazz){
log = Logger.getLogger(clazz.toString());
@@ -17,10 +19,12 @@ public class Jdk14LoggingImpl implements Log {
public void error(String s, Throwable e) {
log.log(Level.SEVERE, s, e);
errorCount++;
}
public void error(String s) {
log.log(Level.SEVERE, s);
errorCount++;
}
public void debug(String s) {
@@ -40,4 +44,13 @@ public class Jdk14LoggingImpl implements Log {
log.log(Level.WARNING, s, e);
}
public int getErrorCount() {
return errorCount;
}
@Override
public void resetStat() {
errorCount = 0;
}
}
@@ -16,4 +16,7 @@ public interface Log {
void warn(String s, Throwable e);
int getErrorCount();
void resetStat();
}
@@ -5,6 +5,8 @@ import org.apache.log4j.Logger;
public class Log4jImpl implements Log {
private Logger log;
private int errorCount;
public Log4jImpl(Class<?> clazz){
log = Logger.getLogger(clazz);
@@ -37,5 +39,13 @@ public class Log4jImpl implements Log {
public void warn(String s, Throwable e) {
log.warn(s, e);
}
public int getErrorCount() {
return errorCount;
}
@Override
public void resetStat() {
errorCount = 0;
}
}
@@ -2,6 +2,8 @@ package com.alibaba.druid.support.logging;
public class NoLoggingImpl implements Log {
private int errorCount;
public NoLoggingImpl(Class<?> clazz){
}
@@ -10,9 +12,11 @@ public class NoLoggingImpl implements Log {
}
public void error(String s, Throwable e) {
errorCount++;
}
public void error(String s) {
errorCount++;
}
public void debug(String s) {
@@ -29,4 +33,12 @@ public class NoLoggingImpl implements Log {
}
public int getErrorCount() {
return errorCount;
}
@Override
public void resetStat() {
errorCount = 0;
}
}