Code example for LogRecord

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

0
 
		child.setParent(parent);
		child.setLevel(Level.INFO);
		parent.setLevel(Level.INFO);
		parent.addHandler(new MockHandler());
		LogRecord r = new LogRecord(Level.INFO, "testLog_ParentInformed");
		child.log(r);
		assertTrue(child.getUseParentHandlers());
		// pop only once, pushed by the parent logger's handler, not by the 
		// parent itself! 
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertTrue(CallVerificationStack.getInstance().empty());
		assertSame(r.getLoggerName(), null);
		assertEquals(r.getMessage(), "testLog_ParentInformed");
		assertSame(r.getResourceBundleName(), null);
		assertSame(r.getSourceClassName(), null);
		assertSame(r.getSourceMethodName(), null);
		assertSame(r.getLevel(), Level.INFO);
		assertNull(r.getParameters());
		assertSame(r.getThrown(), null);
 
		// set the child logger to disabling level 
		child.setLevel(Level.SEVERE);
		child.log(r);
		assertTrue(CallVerificationStack.getInstance().empty());
 
		// set the parent logger to disabling level 
		child.setLevel(Level.INFO);
		parent.setLevel(Level.SEVERE);
		child.log(r);
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertTrue(CallVerificationStack.getInstance().empty());
 
		// set the child logger off 
		child.setLevel(Level.OFF);
		child.log(r);
		assertTrue(CallVerificationStack.getInstance().empty());
 
		// set the record off 
		r.setLevel(Level.OFF);
		child.log(r);
		assertTrue(CallVerificationStack.getInstance().empty());
	} 
 
	/*