@Test public void testForcedLoggingBypassesLoggerIfNeeded() { TestLogger logger = new TestLogger("loggy.mclogface", Level.INFO); TestBackend backend = new TestBackend(logger); backend.log(new LogRecord(Level.INFO, "Enabled and Forced"), true ); logger.assertLogged("Enabled and Forced"); logger.assertPublished("Enabled and Forced"); backend.assertUsedForcingLogger(false); backend.log(new LogRecord(Level.FINE, "Disabled and Forced"), true ); logger.assertLogged(null); logger.assertPublished("Disabled and Forced"); backend.assertUsedForcingLogger(true); }
void log(LogRecord record, boolean wasForced) { if (!wasForced || logger.isLoggable(record.getLevel())) { logger.log(record); } else { Filter filter = logger.getFilter(); if (filter != null) { filter.isLoggable(record); } if (logger.getClass() == Logger.class || cannotUseForcingLogger) { publish(logger, record); } else { forceLoggingViaChildLogger(record); } } }
AbstractBackend extends LoggerBackend { void log(LogRecord record, boolean wasForced) { if (!wasForced || logger.isLoggable(record.getLevel())) { logger.log(record); } else { Filter filter = logger.getFilter(); if (filter != null) { filter.isLoggable(record); } if (logger.getClass() == Logger.class || cannotUseForcingLogger) { publish(logger, record); } else { forceLoggingViaChildLogger(record); } } } }
AbstractBackend extends LoggerBackend { void log(LogRecord record, boolean wasForced) { if (!wasForced || logger.isLoggable(record.getLevel())) { logger.log(record); } else { Filter filter = logger.getFilter(); if (filter != null) { filter.isLoggable(record); } if (logger.getClass() == Logger.class || cannotUseForcingLogger) { publish(logger, record); } else { forceLoggingViaChildLogger(record); } } } AbstractBackend(Logger logger); }
AbstractBackend extends LoggerBackend { void log(LogRecord record, boolean wasForced) { if (!wasForced || logger.isLoggable(record.getLevel())) { logger.log(record); } else { Filter filter = logger.getFilter(); if (filter != null) { filter.isLoggable(record); } if (logger.getClass() == Logger.class || cannotUseForcingLogger) { publish(logger, record); } else { forceLoggingViaChildLogger(record); } } } AbstractBackend(Logger logger); @Override final String getLoggerName(); @Override final boolean isLoggable(Level lvl); }
AbstractBackend extends LoggerBackend { void log(LogRecord record, boolean wasForced) { if (!wasForced || logger.isLoggable(record.getLevel())) { logger.log(record); } else { Filter filter = logger.getFilter(); if (filter != null) { filter.isLoggable(record); } if (logger.getClass() == Logger.class || cannotUseForcingLogger) { publish(logger, record); } else { forceLoggingViaChildLogger(record); } } } AbstractBackend(Logger logger); @Override final String getLoggerName(); @Override final boolean isLoggable(Level lvl);  }