use of org.apache.storm.generated.LogLevel in project storm by apache.
the class LogConfigManagerTest method testProcessRootLogLevelToDebugSetsLoggerAndTimeout2.
@Test
public void testProcessRootLogLevelToDebugSetsLoggerAndTimeout2() {
try (SimulatedTime t = new SimulatedTime()) {
LogConfig mockConfig = new LogConfig();
AtomicReference<TreeMap<String, LogLevel>> mockConfigAtom = new AtomicReference<>(null);
long inThirtySeconds = Time.currentTimeMillis() + 30_000;
mockConfig.put_to_named_logger_level("ROOT", ll("DEBUG", inThirtySeconds));
LogConfigManager underTest = spy(new LogConfigManagerUnderTest(mockConfigAtom));
underTest.processLogConfigChange(mockConfig);
// test that the set-logger-level function was not called
LOG.info("Tests {}", mockConfigAtom.get());
verify(underTest).setLoggerLevel(anyObject(), eq(""), eq("DEBUG"));
LogLevel rootResult = mockConfigAtom.get().get(LogManager.ROOT_LOGGER_NAME);
assertNotNull(rootResult);
assertEquals(LogLevelAction.UPDATE, rootResult.get_action());
assertEquals("DEBUG", rootResult.get_target_log_level());
// defaults to INFO level when the logger isn't found previously
assertEquals("INFO", rootResult.get_reset_log_level());
assertEquals(inThirtySeconds, rootResult.get_reset_log_level_timeout_epoch());
}
}
use of org.apache.storm.generated.LogLevel in project storm by apache.
the class SetLogLevelTest method testUpdateLogLevelParser.
@Test
public void testUpdateLogLevelParser() {
SetLogLevel.LogLevelsParser logLevelsParser = new SetLogLevel.LogLevelsParser(LogLevelAction.UPDATE);
LogLevel logLevel = ((Map<String, LogLevel>) logLevelsParser.parse("com.foo.one=warn")).get("com.foo.one");
Assert.assertEquals(0, logLevel.get_reset_log_level_timeout_secs());
Assert.assertEquals("WARN", logLevel.get_reset_log_level());
logLevel = ((Map<String, LogLevel>) logLevelsParser.parse("com.foo.two=DEBUG:10")).get("com.foo.two");
Assert.assertEquals(10, logLevel.get_reset_log_level_timeout_secs());
Assert.assertEquals("DEBUG", logLevel.get_reset_log_level());
}
Aggregations