Remove LogLevel enum and associated code

This commit is contained in:
Robin Bygrave
2013-04-28 00:29:30 +12:00
parent 513a61503e
commit e79a5d4332
14 changed files with 39 additions and 175 deletions
@@ -1,25 +0,0 @@
package com.avaje.ebean;
/**
* The transaction log level.
* <p>
* This is used to define how much Ebean should log such as generated SQL.
* </p>
*/
public enum LogLevel {
/**
* No logging.
*/
NONE,
/**
* Log only a summary level.
*/
SUMMARY,
/**
* Log generated SQL/DML and binding variables.
*/
SQL
}
@@ -51,29 +51,6 @@ public interface Transaction {
*/
public void setReadOnly(boolean readOnly);
// /**
// * Log a comment to the transaction log.
// */
// public void log(String msg);
/**
* Set the logLevel to use for this transaction.
*/
public void setLogLevel(LogLevel logLevel);
/**
* Return the logLevel this transaction is using.
*/
public LogLevel getLogLevel();
/**
* Deprecated in favour of using {@link #setLogLevel} Set this to false to
* disable logging for this transaction.
*
* @deprecated
*/
public void setLoggingOn(boolean isLoggingOn);
/**
* Commit the transaction.
*/
@@ -6,7 +6,6 @@ import java.util.List;
import javax.sql.DataSource;
import com.avaje.ebean.EbeanServerFactory;
import com.avaje.ebean.LogLevel;
import com.avaje.ebean.annotation.Encrypted;
import com.avaje.ebean.cache.ServerCacheFactory;
import com.avaje.ebean.cache.ServerCacheManager;
@@ -162,11 +161,6 @@ public class ServerConfig {
*/
private String loggingDirectory = "logs";
/**
* The overall transaction logging level.
*/
private LogLevel loggingLevel = LogLevel.NONE;
/**
* Used to unwrap PreparedStatements to perform JDBC Driver specific functions
*/
@@ -816,26 +810,6 @@ public class ServerConfig {
this.debugLazyLoad = debugLazyLoad;
}
/**
* Return the default transaction logging level.
* <p>
* The logging level can be changed on a per transaction basis.
* </p>
*/
public LogLevel getLoggingLevel() {
return loggingLevel;
}
/**
* Set the default transaction logging level.
* <p>
* The logging level can be changed on a per transaction basis.
* </p>
*/
public void setLoggingLevel(LogLevel logLevel) {
this.loggingLevel = logLevel;
}
/**
* Return the directory where transaction logs go.
*/
@@ -1359,8 +1333,6 @@ public class ServerConfig {
debugSql = p.getBoolean("debug.sql", false);
debugLazyLoad = p.getBoolean("debug.lazyload", false);
loggingLevel = getLogLevelValue(p);
String s = p.get("useJuliTransactionLogger", null);
s = p.get("loggingToJavaLogger", s);
loggingToJavaLogger = "true".equalsIgnoreCase(s);
@@ -1371,17 +1343,6 @@ public class ServerConfig {
classes = getClasses(p);
}
private LogLevel getLogLevelValue(PropertySource p) {
// logging.level preferred but others parameters will work
String logValue = p.get("logging", "NONE");
logValue = p.get("log.level", logValue);
logValue = p.get("logging.level", logValue);
if (logValue.trim().equalsIgnoreCase("ALL")) {
logValue = "SQL";
}
return Enum.valueOf(LogLevel.class, logValue.toUpperCase());
}
private NamingConvention createNamingConvention(PropertySource p) {
NamingConvention nc = createInstance(p, NamingConvention.class, "namingconvention");
@@ -3,7 +3,6 @@ package com.avaje.ebeaninternal.server.core;
import java.sql.Connection;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.LogLevel;
import com.avaje.ebeaninternal.api.SpiEbeanServer;
import com.avaje.ebeaninternal.api.SpiTransaction;
@@ -115,13 +114,13 @@ public abstract class BeanRequest {
* Return true if SQL should be logged for this transaction.
*/
public boolean isLogSql() {
return transaction.getLogLevel().ordinal() >= LogLevel.SQL.ordinal();
return transaction.isLogSql();
}
/**
* Return true if SUMMARY information should be logged for this transaction.
*/
public boolean isLogSummary() {
return transaction.getLogLevel().ordinal() >= LogLevel.SUMMARY.ordinal();
return transaction.isLogSummary();
}
}
@@ -5,8 +5,6 @@ import java.sql.Connection;
import javax.persistence.PersistenceException;
import javax.persistence.RollbackException;
import com.avaje.ebean.LogLevel;
/**
* Transaction based on a java.sql.Connection supplied by an external
* transaction manager such as Spring.
@@ -29,21 +27,14 @@ public class ExternalJdbcTransaction extends JdbcTransaction {
* </p>
*/
public ExternalJdbcTransaction(Connection connection) {
super(null, true, LogLevel.NONE, connection, null);
}
/**
* Using the TransactionManager and its current LogLevel.
*/
public ExternalJdbcTransaction(String id, boolean explicit, Connection connection, TransactionManager manager) {
super(id, explicit, manager.getTransactionLogLevel(), connection, manager);
super(null, true, connection, null);
}
/**
* Construct will all explicit parameters.
*/
public ExternalJdbcTransaction(String id, boolean explicit, LogLevel logLevel, Connection connection, TransactionManager manager) {
super(id, explicit, logLevel, connection, manager);
public ExternalJdbcTransaction(String id, boolean explicit, Connection connection, TransactionManager manager) {
super(id, explicit, connection, manager);
}
/**
@@ -15,7 +15,6 @@ import javax.persistence.RollbackException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.avaje.ebean.LogLevel;
import com.avaje.ebean.bean.PersistenceContext;
import com.avaje.ebeaninternal.api.DerivedRelationshipData;
import com.avaje.ebeaninternal.api.SpiTransaction;
@@ -98,8 +97,6 @@ public class JdbcTransaction implements SpiTransaction {
boolean localReadOnly;
LogLevel logLevel;
/**
* Set to true if using batch processing.
*/
@@ -129,13 +126,12 @@ public class JdbcTransaction implements SpiTransaction {
/**
* Create a new JdbcTransaction.
*/
public JdbcTransaction(String id, boolean explicit, LogLevel logLevel, Connection connection, TransactionManager manager) {
public JdbcTransaction(String id, boolean explicit, Connection connection, TransactionManager manager) {
try {
this.active = true;
this.id = id;
this.logPrefix = deriveLogPrefix(id,null);
this.explicit = explicit;
this.logLevel = logLevel;
this.manager = manager;
this.connection = connection;
this.autoCommit = connection.getAutoCommit();
@@ -456,11 +452,7 @@ public class JdbcTransaction implements SpiTransaction {
* Set whether transaction logging is on for this transaction.
*/
public void setLoggingOn(boolean loggingOn) {
if (loggingOn) {
logLevel = LogLevel.SQL;
} else {
logLevel = LogLevel.NONE;
}
}
/**
@@ -477,14 +469,6 @@ public class JdbcTransaction implements SpiTransaction {
public boolean isLogSummary() {
return TransactionManager.SUM_LOGGER.isDebugEnabled();
}
public LogLevel getLogLevel() {
return logLevel;
}
public void setLogLevel(LogLevel logLevel) {
this.logLevel = logLevel;
}
public void logSql(String msg) {
TransactionManager.SQL_LOGGER.trace(logPrefix+msg);
@@ -7,8 +7,6 @@ import javax.sql.DataSource;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
import com.avaje.ebean.LogLevel;
/**
* Jta based transaction.
*/
@@ -26,8 +24,8 @@ public class JtaTransaction extends JdbcTransaction {
/**
* Create the JtaTransaction.
*/
public JtaTransaction(String id, boolean explicit, LogLevel logLevel, UserTransaction utx, DataSource ds, TransactionManager manager) {
super(id, explicit, logLevel, null, manager);
public JtaTransaction(String id, boolean explicit, UserTransaction utx, DataSource ds, TransactionManager manager) {
super(id, explicit, null, manager);
userTransaction = utx;
dataSource = ds;
@@ -14,12 +14,12 @@ import javax.transaction.SystemException;
import javax.transaction.TransactionSynchronizationRegistry;
import javax.transaction.UserTransaction;
import com.avaje.ebean.LogLevel;
import com.avaje.ebean.config.ExternalTransactionManager;
import com.avaje.ebeaninternal.api.SpiTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.avaje.ebean.config.ExternalTransactionManager;
import com.avaje.ebeaninternal.api.SpiTransaction;
/**
* Hook into external JTA transaction manager.
*
@@ -122,7 +122,7 @@ public class JtaTransactionManager implements ExternalTransactionManager {
// "wrap" it in a Ebean specific JtaTransaction
String txnId = String.valueOf(System.currentTimeMillis());
JtaTransaction newTrans = new JtaTransaction(txnId, true, LogLevel.NONE, ut, dataSource, transactionManager);
JtaTransaction newTrans = new JtaTransaction(txnId, true, ut, dataSource, transactionManager);
// create and register transaction listener
JtaTxnListener txnListener = createJtaTxnListener(newTrans);
@@ -13,7 +13,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.avaje.ebean.BackgroundExecutor;
import com.avaje.ebean.LogLevel;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebean.event.TransactionEventListener;
@@ -66,8 +65,6 @@ public class TransactionManager {
private final BeanDescriptorManager beanDescriptorManager;
private LogLevel logLevel;
/**
* Prefix for transaction id's (logging).
*/
@@ -118,9 +115,7 @@ public class TransactionManager {
this.beanDescriptorManager = descMgr;
this.clusterManager = clusterManager;
this.serverName = config.getName();
this.logLevel = config.getLoggingLevel();
this.serverName = config.getName();
this.backgroundExecutor = backgroundExecutor;
this.dataSource = config.getDataSource();
this.bulkEventListenerMap = new BulkEventListenerMap(config.getBulkTableEventListeners());
@@ -162,20 +157,6 @@ public class TransactionManager {
public BulkEventListenerMap getBulkEventListenerMap() {
return bulkEventListenerMap;
}
/**
* Return the logging level for transactions.
*/
public LogLevel getTransactionLogLevel(){
return logLevel;
}
/**
* Set the log level for transactions.
*/
public void setTransactionLogLevel(LogLevel logLevel){
this.logLevel = logLevel;
}
/**
* Return the behaviour to use when a query only transaction is committed.
@@ -276,7 +257,7 @@ public class TransactionManager {
*/
public SpiTransaction wrapExternalConnection(String id, Connection c) {
ExternalJdbcTransaction t = new ExternalJdbcTransaction(id, true, logLevel, c, this);
ExternalJdbcTransaction t = new ExternalJdbcTransaction(id, true, c, this);
// set the default batch mode. This can be on for
// jdbc drivers that support getGeneratedKeys
@@ -296,7 +277,7 @@ public class TransactionManager {
c = dataSource.getConnection();
long id = transactionCounter.incrementAndGet();
JdbcTransaction t = new JdbcTransaction(prefix + id, explicit, logLevel, c, this);
JdbcTransaction t = new JdbcTransaction(prefix + id, explicit, c, this);
// set the default batch mode. This can be on for
// jdbc drivers that support getGeneratedKeys
@@ -332,7 +313,7 @@ public class TransactionManager {
c = dataSource.getConnection();
long id = transactionCounter.incrementAndGet();
JdbcTransaction t = new JdbcTransaction(prefix + id, false, logLevel, c, this);
JdbcTransaction t = new JdbcTransaction(prefix + id, false, c, this);
// set the default batch mode. Can be true for
// jdbc drivers that support getGeneratedKeys