Code example for LogRecord

Methods: getLevel, setLevel

0
	/* 
	 * Test that a logger with null level and no parent. Defaulted to 
	 * Level.INFO. 
	 */ 
	public void testLog_NullLevelNoParent() { 
		LogRecord r = new LogRecord(Level.INFO, "testLog_NullLevelNoParent");
		assertNull(this.sharedLogger.getLevel());
		assertNull(this.sharedLogger.getParent());
		assertTrue(this.sharedLogger.isLoggable(r.getLevel()));
		this.sharedLogger.log(r);
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertTrue(CallVerificationStack.getInstance().empty());
		assertNull(this.sharedLogger.getLevel());
 
		r.setLevel(Level.WARNING);
		assertTrue(this.sharedLogger.isLoggable(r.getLevel()));
		this.sharedLogger.log(r);
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertTrue(CallVerificationStack.getInstance().empty());
 
		r.setLevel(Level.CONFIG);
		this.sharedLogger.log(r);
		assertFalse(this.sharedLogger.isLoggable(r.getLevel()));
		assertTrue(CallVerificationStack.getInstance().empty());
	} 
 
	/* 
	 * Test that a logger inherits its parent level when its level is null.