use of org.jboss.logmanager.handlers.AsyncHandler in project quarkus by quarkusio.
the class AsyncConsoleHandlerTest method asyncConsoleHandlerConfigurationTest.
@Test
public void asyncConsoleHandlerConfigurationTest() {
Handler handler = getHandler(AsyncHandler.class);
assertThat(handler.getLevel()).isEqualTo(Level.WARNING);
AsyncHandler asyncHandler = (AsyncHandler) handler;
assertThat(asyncHandler.getHandlers()).isNotEmpty();
assertThat(asyncHandler.getQueueLength()).isEqualTo(256);
assertThat(asyncHandler.getOverflowAction()).isEqualTo(AsyncHandler.OverflowAction.DISCARD);
Handler nestedConsoleHandler = Arrays.stream(asyncHandler.getHandlers()).filter(h -> (h instanceof ConsoleHandler)).findFirst().get();
ConsoleHandler consoleHandler = (ConsoleHandler) nestedConsoleHandler;
assertThat(consoleHandler.getLevel()).isEqualTo(Level.WARNING);
}
use of org.jboss.logmanager.handlers.AsyncHandler in project quarkus by quarkusio.
the class AsyncSyslogHandlerTest method asyncSyslogHandlerConfigurationTest.
@Test
public void asyncSyslogHandlerConfigurationTest() throws NullPointerException {
Handler handler = getHandler(AsyncHandler.class);
assertThat(handler.getLevel()).isEqualTo(Level.WARNING);
AsyncHandler asyncHandler = (AsyncHandler) handler;
assertThat(asyncHandler.getHandlers()).isNotEmpty();
assertThat(asyncHandler.getQueueLength()).isEqualTo(256);
assertThat(asyncHandler.getOverflowAction()).isEqualTo(AsyncHandler.OverflowAction.DISCARD);
Handler nestedSyslogHandler = Arrays.stream(asyncHandler.getHandlers()).filter(h -> (h instanceof SyslogHandler)).findFirst().get();
SyslogHandler syslogHandler = (SyslogHandler) nestedSyslogHandler;
assertThat(syslogHandler.getPort()).isEqualTo(5144);
assertThat(syslogHandler.getAppName()).isEqualTo("quarkus");
assertThat(syslogHandler.getHostname()).isEqualTo("quarkus-test");
assertThat(syslogHandler.getFacility()).isEqualTo(SyslogHandler.Facility.LOG_ALERT);
assertThat(syslogHandler.getSyslogType()).isEqualTo(SyslogHandler.SyslogType.RFC3164);
assertThat(syslogHandler.getProtocol()).isEqualTo(SyslogHandler.Protocol.UDP);
assertThat(syslogHandler.isUseCountingFraming()).isEqualTo(true);
assertThat(syslogHandler.isTruncate()).isEqualTo(false);
assertThat(syslogHandler.isBlockOnReconnect()).isEqualTo(false);
}
use of org.jboss.logmanager.handlers.AsyncHandler in project quarkus by quarkusio.
the class ApplicationLifecycleManager method ensureConsoleLogsDrained.
// this is needed only when async console logging is enabled
private static void ensureConsoleLogsDrained() {
AsyncHandler asyncHandler = null;
for (Handler handler : InitialConfigurator.DELAYED_HANDLER.getHandlers()) {
if (handler instanceof AsyncHandler) {
asyncHandler = (AsyncHandler) handler;
Handler[] nestedHandlers = asyncHandler.getHandlers();
boolean foundNestedConsoleHandler = false;
for (Handler nestedHandler : nestedHandlers) {
if (nestedHandler instanceof ConsoleHandler) {
foundNestedConsoleHandler = true;
break;
}
}
if (!foundNestedConsoleHandler) {
asyncHandler = null;
}
}
if (asyncHandler != null) {
break;
}
}
if (asyncHandler != null) {
try {
// all we can do is wait because the thread that takes records off the queue is a daemon thread and there is no way to interact with its lifecycle
Thread.sleep(200);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
use of org.jboss.logmanager.handlers.AsyncHandler in project quarkus by quarkusio.
the class LoggingSetupRecorder method createAsyncHandler.
private static AsyncHandler createAsyncHandler(AsyncConfig asyncConfig, Level level, Handler handler) {
final AsyncHandler asyncHandler = new AsyncHandler(asyncConfig.queueLength);
asyncHandler.setOverflowAction(asyncConfig.overflow);
asyncHandler.addHandler(handler);
asyncHandler.setLevel(level);
return asyncHandler;
}
use of org.jboss.logmanager.handlers.AsyncHandler in project quarkus by quarkusio.
the class AsyncFileHandlerTest method asyncFileHandlerConfigurationTest.
@Test
public void asyncFileHandlerConfigurationTest() {
Handler handler = getHandler(AsyncHandler.class);
assertThat(handler.getLevel()).isEqualTo(Level.INFO);
AsyncHandler asyncHandler = (AsyncHandler) handler;
assertThat(asyncHandler.getHandlers()).isNotEmpty();
assertThat(asyncHandler.getQueueLength()).isEqualTo(1024);
assertThat(asyncHandler.getOverflowAction()).isEqualTo(AsyncHandler.OverflowAction.BLOCK);
Handler nestedFileHandler = Arrays.stream(asyncHandler.getHandlers()).filter(h -> (h instanceof FileHandler)).findFirst().get();
FileHandler fileHandler = (FileHandler) nestedFileHandler;
assertThat(fileHandler.getLevel()).isEqualTo(Level.INFO);
}
Aggregations