public static void logElapsed(int connectionId, long timeElapsedNanos, Category category, String prepared, String sql, String url) { if (logger != null && meetsThresholdRequirement(timeElapsedNanos) && isCategoryOk(category) && isLoggable(sql) ) { doLogElapsed(connectionId, timeElapsedNanos, category, prepared, sql, url == null ? "" : url); } else if (isDebugEnabled()) { debug("P6Spy intentionally did not log category: " + category + ", statement: " + sql + " Reason: logger=" + logger + ", isLoggable=" + isLoggable(sql) + ", isCategoryOk=" + isCategoryOk(category) + ", meetsTreshold=" + meetsThresholdRequirement(timeElapsedNanos)); } }
public static int parseInt(String i, int defaultValue) { if (i == null || i.isEmpty()) { return defaultValue; } try { return (Integer.parseInt(i)); } catch(NumberFormatException nfe) { P6LogQuery.error("NumberFormatException occured parsing value "+i); return defaultValue; } }
public void optionChanged(final String key, final Object oldValue, final Object newValue) { if (ON_CHANGE.contains(key)) { initialize(); } }
public static void log(Category category, String prepared, String sql) { if (logger != null && isCategoryOk(category)) { doLog(-1, category, prepared, sql); } }
public static void debug(String sql) { if (isDebugEnabled()) { if (logger != null) { doLog(-1, Category.DEBUG, "", sql); } else { System.err.println(sql); } } }
private void debug(String msg) { // not initialized yet => nowhere to log yet if (instance == null || factories.isEmpty()) { return; } P6LogQuery.debug(msg); }
private void assertDefaultDisabledLogCategories() throws IOException { P6LogQuery.debug(msg); if( LOG_FILE.exists() ) { final String logged = FileUtils.readFileToString(LOG_FILE, "UTF-8"); P6LogQuery.info(msg); if( LOG_FILE.exists() ) { final String logged = FileUtils.readFileToString(LOG_FILE, "UTF-8"); P6LogQuery.error(msg); if( LOG_FILE.exists() ) { final String logged = FileUtils.readFileToString(LOG_FILE, "UTF-8");
public static void log(Category category, Loggable loggable) { if (logger != null && isCategoryOk(category) && isLoggable(loggable.getSql())) { doLog(-1, category, loggable.getSql(), loggable.getSqlWithValues()); } }
private void failOnNonP6TestLoggerUsage() { if (!(P6LogQuery.getLogger() instanceof P6TestLogger)) { throw new IllegalStateException(); } }
/** * Generates log message with column values accessed if the row's column values have not already been logged. */ public void generateLogMessage() { if (lastRowLogged != currRow) { P6LogQuery.log(Category.RESULTSET, this); resultMap.clear(); lastRowLogged = currRow; } }
registerOptionChangedListener(new P6LogQuery());
protected static void doLogElapsed(int connectionId, long timeElapsedNanos, Category category, String prepared, String sql, String url) { doLog(connectionId, timeElapsedNanos, category, prepared, sql, url); }
public static boolean isDebugEnabled() { return isCategoryOk(Category.DEBUG); }
/** Creates new P6OutageDetector */ private P6OutageDetector() { pendingMessages = new ConcurrentHashMap<Object, InvocationInfo>(); // create and run the auxilliary thread // make it a deamon thread so it won't prevent the server from // shutting down when it wants to. ThreadGroup group = new ThreadGroup("P6SpyThreadGroup"); group.setDaemon(true); Thread outageThread = new Thread(group, this, "P6SpyOutageThread"); outageThread.start(); P6LogQuery.debug("P6Spy - P6OutageDetector has been invoked."); P6LogQuery.debug("P6Spy - P6OutageOptions.getOutageDetectionIntervalMS() = " + P6OutageOptions.getActiveInstance().getOutageDetectionIntervalMS()); }
public static void log(Category category, Loggable loggable) { if (logger != null && isCategoryOk(category) && isLoggable(loggable.getSql())) { doLog(-1, category, loggable.getSql(), loggable.getSqlWithValues()); } }
public static void info(String sql) { if (logger != null && isCategoryOk(Category.INFO)) { doLog(-1, Category.INFO, "", sql); } }
private P6TestLogger getP6TestLogger() { failOnNonP6TestLoggerUsage(); return (P6TestLogger) P6LogQuery.getLogger(); } }
public static void debug(String sql) { if (isDebugEnabled()) { if (logger != null) { doLog(-1, Category.DEBUG, "", sql); } else { System.err.println(sql); } } }
public void checkCategoryToLevelMapping(Category category, Level expectedLevel, Level thresholdLevel) throws Exception { configure(thresholdLevel.toString(), true); Log4JTestApppender.clearCapturedMessages(); P6LogQuery.log(category, "sample msg", "sample msg"); if (expectedLevel == null) { assertEquals(0, Log4JTestApppender.getCapturedMessages().size()); } else { assertEquals(1, Log4JTestApppender.getCapturedMessages().size()); assertEquals(expectedLevel, Log4JTestApppender.getCapturedMessages().get(0).getLevel()); } }
registerOptionChangedListener(new P6LogQuery());