Code example for LogRecord

Methods: setLevel

0
		LogManager.getLogManager().readConfiguration(
				EnvironmentHelper.PropertiesToInputStream(p));
		ConsoleHandler h = new ConsoleHandler();
		h.setFilter(new MockFilter());
 
		LogRecord r = new LogRecord(Level.INFO, "testPublish_WithFilter");
		h.setLevel(Level.INFO);
		h.publish(r);
		assertNull(CallVerificationStack.getInstance().pop());
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertEquals("", this.errSubstituteStream.toString());
 
		h.setLevel(Level.WARNING);
		h.publish(r);
		assertNull(CallVerificationStack.getInstance().pop());
		assertTrue(CallVerificationStack.getInstance().empty());
		assertEquals("", this.errSubstituteStream.toString());
 
		h.setLevel(Level.CONFIG);
		h.publish(r);
		assertNull(CallVerificationStack.getInstance().pop());
		assertSame(r, CallVerificationStack.getInstance().pop());
		assertEquals("", this.errSubstituteStream.toString());
 
		r.setLevel(Level.OFF);
		h.setLevel(Level.OFF);
		h.publish(r);
		assertNull(CallVerificationStack.getInstance().pop());
		assertEquals("", this.errSubstituteStream.toString());
		assertTrue(CallVerificationStack.getInstance().empty());
Experience pair programming with AI  Get Codota for Java