Refactor transaction logging to simple SLF4J use

This commit is contained in:
Robin Bygrave committed 2013-04-15 23:16:08 +12:00
1 parent b5ef07bab9
commit cbd7b5e912
60 files changed
+2976 -4529

No files matched your search

@@ -69,8 +69,6 @@ public class DefaultAutoFetchManager implements AutoFetchManager, Serializable {
private transient boolean queryTuningAddVersion;
private transient AutofetchMode mode;
private transient boolean useFileLogging;
/**
* Server that owns this Profile Listener.
@@ -95,7 +93,6 @@ public class DefaultAutoFetchManager implements AutoFetchManager, Serializable {
AutofetchConfig autofetchConfig = serverConfig.getAutofetchConfig();
useFileLogging = autofetchConfig.isUseFileLogging();
queryTuning = autofetchConfig.isQueryTuning();
queryTuningAddVersion = autofetchConfig.isQueryTuningAddVersion();
profiling = autofetchConfig.isProfiling();
@@ -116,7 +113,7 @@ public class DefaultAutoFetchManager implements AutoFetchManager, Serializable {
String msg = "AutoFetch queryTuning[" + queryTuning + "] profiling[" + profiling
+ "] mode[" + mode + "] profiling rate[" + profilingRate
+ "] min[" + profilingMin + "] base[" + profilingBase + "]";
logging.logToJavaLogger(msg);
logging.logInfo(msg, null);
}
}
@@ -272,10 +269,10 @@ public class DefaultAutoFetchManager implements AutoFetchManager, Serializable {
* </p>
*/
public void shutdown() {
if (useFileLogging) {
//if (useFileLogging) {
collectUsageViaGC(-1);
serialize();
}
//}
}
/**
@@ -1,15 +1,13 @@
package com.avaje.ebeaninternal.server.autofetch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.avaje.ebean.config.AutofetchConfig;
import com.avaje.ebean.config.GlobalProperties;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebeaninternal.server.lib.BackgroundThread;
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
import com.avaje.ebeaninternal.server.transaction.log.SimpleLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Level;
/**
* Handles the logging aspects for the DefaultAutoFetchListener.
@@ -22,12 +20,8 @@ public class DefaultAutoFetchManagerLogging {
private static final Logger logger = LoggerFactory.getLogger(DefaultAutoFetchManagerLogging.class);
private final SimpleLogger fileLogger;
private final DefaultAutoFetchManager manager;
private final boolean useFileLogger;
private final boolean traceUsageCollection;
public DefaultAutoFetchManagerLogging(ServerConfig serverConfig, DefaultAutoFetchManager profileListener) {
@@ -37,21 +31,8 @@ public class DefaultAutoFetchManagerLogging {
AutofetchConfig autofetchConfig = serverConfig.getAutofetchConfig();
traceUsageCollection = GlobalProperties.getBoolean("ebean.autofetch.traceUsageCollection", false);
useFileLogger = autofetchConfig.isUseFileLogging();
if (!useFileLogger) {
fileLogger = null;
} else {
// a separate log file just like the transaction logging
// for putting the profiling log messages. The benefit is that
// this doesn't pollute the main log with heaps of messages.
String baseDir = serverConfig.getLoggingDirectoryWithEval();
fileLogger = new SimpleLogger(baseDir, "autofetch", true, "csv");
}
int updateFreqInSecs = autofetchConfig.getProfileUpdateFrequency();
BackgroundThread.add(updateFreqInSecs, new UpdateProfile());
}
@@ -61,63 +42,30 @@ public class DefaultAutoFetchManagerLogging {
}
}
private void logFile(String msg, Throwable e) {
if (useFileLogger) {
String errMsg = e == null ? "" : e.getMessage();
fileLogger.log("\"Error\",\"" + msg+" "+errMsg+"\",,,,");
}
}
public void logInfo(String msg, Throwable e) {
logFile(msg, e);
logger.info(msg, e);
}
public void logError(String msg, Throwable e) {
logFile(msg, e);
logger.error(msg, e);
}
@Deprecated
public void logError(Level level, String msg, Throwable e) {
logError(msg, e);
}
public void logToJavaLogger(String msg) {
logger.info(msg);
}
public void logSummary(String summaryInfo) {
String msg = "\"Summary\",\""+summaryInfo+"\",,,,";
if (useFileLogger) {
fileLogger.log(msg);
}
String msg = "\"Summary\",\""+summaryInfo+"\",,,,";
logger.debug(msg);
}
public void logChanged(TunedQueryInfo tunedFetch, OrmQueryDetail newQueryDetail) {
String msg = tunedFetch.getLogOutput(newQueryDetail);
if (useFileLogger) {
fileLogger.log(msg);
} else {
logger.debug(msg);
}
logger.debug(msg);
}
public void logNew(TunedQueryInfo tunedFetch) {
String msg = tunedFetch.getLogOutput(null);
if (useFileLogger) {
fileLogger.log(msg);
} else {
logger.debug(msg);
}
logger.debug(msg);
}
public boolean isTraceUsageCollection() {