Java Code Examples for java.util.logging.Logger#setParent()
The following examples show how to use
java.util.logging.Logger#setParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvironmentLogger.java From baratine with GNU General Public License v2.0 | 6 votes |
/** * Sets a custom logger if possible */ public boolean addCustomLogger(Logger logger) { if (logger.getClass().getName().startsWith("java")) return false; Logger oldLogger = _localLoggers.get(); if (oldLogger != null) return false; _localLoggers.set(logger); if (_parent != null) { logger.setParent(_parent); } return true; }
Example 2
Source File: ClassesTest.java From Skript with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings({"resource", "deprecation"}) @Before public void before() throws Exception { final File dataDir = new File("build/resources/"); final File jar = new File("build/", "skript.jar"); assumeTrue(jar.exists()); final Logger l = Logger.getLogger(getClass().getCanonicalName()); l.setParent(SkriptLogger.LOGGER); l.setLevel(Level.WARNING); final Server s = createMock(Server.class); s.getLogger(); expectLastCall().andReturn(l).anyTimes(); s.isPrimaryThread(); expectLastCall().andReturn(true).anyTimes(); s.getName(); expectLastCall().andReturn("Whatever").anyTimes(); s.getVersion(); expectLastCall().andReturn("2.0").anyTimes(); s.getBukkitVersion(); expectLastCall().andReturn("2.0").anyTimes(); replay(s); Bukkit.setServer(s); final Skript skript = (Skript) ObjenesisHelper.newInstance(Skript.class); // bypass the class loader check final Field instance = Skript.class.getDeclaredField("instance"); instance.setAccessible(true); instance.set(null, skript); final PluginDescriptionFile pdf = new PluginDescriptionFile(new FileInputStream(new File(dataDir, "plugin.yml"))); // final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) { final Method init = JavaPlugin.class.getDeclaredMethod("init", PluginLoader.class, Server.class, PluginDescriptionFile.class, File.class, File.class, ClassLoader.class); init.setAccessible(true); init.invoke(skript, new JavaPluginLoader(s), s, pdf, dataDir, jar, getClass().getClassLoader()); Skript.getAddonInstance().loadClasses("ch.njol.skript", "entity"); new JavaClasses(); new BukkitClasses(); new BukkitEventValues(); new SkriptClasses(); final Field r = Skript.class.getDeclaredField("acceptRegistrations"); r.setAccessible(true); r.set(null, false); Classes.onRegistrationsStop(); }
Example 3
Source File: Loggers.java From mochadoom with GNU General Public License v3.0 | 4 votes |
public static Logger getLogger(final String className) { final Logger ret = Logger.getLogger(className); ret.setParent(INDIVIDUAL_CLASS_LOGGERS.getOrDefault(className, DEFAULT_LOGGER)); return ret; }
Example 4
Source File: TestAnonymousLogger.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 5
Source File: TestAnonymousLogger.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 6
Source File: LogWrapper.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public void setParentFor(Logger otherLogger) { if (otherLogger.getParent() != logger) { otherLogger.setParent(logger); } }
Example 7
Source File: TestAnonymousLogger.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 8
Source File: TestAnonymousLogger.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 9
Source File: LogWrapper.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public void setParentFor(Logger otherLogger) { if (otherLogger.getParent() != logger) { otherLogger.setParent(logger); } }
Example 10
Source File: TestAnonymousLogger.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 11
Source File: TestAnonymousLogger.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 12
Source File: TestAnonymousLogger.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 13
Source File: TestAnonymousLogger.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 14
Source File: TestAnonymousLogger.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 15
Source File: TestAnonymousLogger.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 16
Source File: TestAnonymousLogger.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 17
Source File: TestAnonymousLogger.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }
Example 18
Source File: TestAnonymousLogger.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { System.setSecurityManager(new SecurityManager()); Logger anonymous = Logger.getAnonymousLogger(); final TestHandler handler = new TestHandler(); final TestFilter filter = new TestFilter(); final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName()); anonymous.setLevel(Level.FINEST); anonymous.addHandler(handler); anonymous.setFilter(filter); anonymous.setUseParentHandlers(true); anonymous.setResourceBundle(bundle); if (anonymous.getLevel() != Level.FINEST) { throw new RuntimeException("Unexpected level: " + anonymous.getLevel()); } else { System.out.println("Got expected level: " + anonymous.getLevel()); } if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) { throw new RuntimeException("Expected handler not found in: " + Arrays.asList(anonymous.getHandlers())); } else { System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers())); } if (anonymous.getFilter() != filter) { throw new RuntimeException("Unexpected filter: " + anonymous.getFilter()); } else { System.out.println("Got expected filter: " + anonymous.getFilter()); } if (!anonymous.getUseParentHandlers()) { throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers()); } else { System.out.println("Got expected flag: " + anonymous.getUseParentHandlers()); } if (anonymous.getResourceBundle() != bundle) { throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle()); } else { System.out.println("Got expected bundle: " + anonymous.getResourceBundle()); } try { anonymous.setParent(Logger.getLogger("foo.bar")); throw new RuntimeException("Expected SecurityException not raised!"); } catch (SecurityException x) { System.out.println("Got expected exception: " + x); } if (anonymous.getParent() != Logger.getLogger("")) { throw new RuntimeException("Unexpected parent: " + anonymous.getParent()); } else { System.out.println("Got expected parent: " + anonymous.getParent()); } }