Code example for LogRecord

Methods: getLevel, getLoggerName, getMessage, getParameters, getResourceBundleName, getSourceClassName, getSourceMethodName, getThrown

0
		child.setParent(parent);
		parent.setLevel(Level.FINER);
 
		assertNull(child.getLevel());
 
		LogRecord r = new LogRecord(Level.FINE, "testLog_NullLevelHasParent");
		child.log(r);
		assertTrue(child.isLoggable(r.getLevel()));
		// pop only once, pushed by the child logger's handler 
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertTrue(CallVerificationStack.getInstance().empty());
 
		assertSame(r.getLoggerName(), null);
		assertEquals(r.getMessage(), "testLog_NullLevelHasParent");
		assertSame(r.getResourceBundleName(), null);
		assertSame(r.getSourceClassName(), null);
		assertSame(r.getSourceMethodName(), null);
		assertSame(r.getLevel(), Level.FINE);
		assertNull(r.getParameters());
		assertSame(r.getThrown(), null);
		assertNull(child.getLevel());
 
		// set the parent logger to disabling level 
		parent.setLevel(Level.CONFIG);
		assertFalse(child.isLoggable(r.getLevel()));
		child.log(r);
		assertTrue(CallVerificationStack.getInstance().empty());
		assertNull(child.getLevel());
 
		// test ancestor 
		Logger ancestor = new MockLogger("ancestorLogger",
				VALID_RESOURCE_BUNDLE3);
		parent.setParent(ancestor);
		parent.setLevel(null);
		parent.setUseParentHandlers(false);
		ancestor.setLevel(Level.ALL);
		child.log(r);
		assertTrue(child.isLoggable(r.getLevel()));
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertTrue(CallVerificationStack.getInstance().empty());
		assertNull(child.getLevel());
		assertNull(parent.getLevel());
	}