SubutaiAppender extends AppenderSkeleton { @Override protected void append( final LoggingEvent event ) { try { if ( event.getLevel().isGreaterOrEqual( MIN_REPORT_LOG_LEVEL ) && event.getThrowableInformation() != null && event.getThrowableInformation().getThrowable() != null ) { StringWriter errors = new StringWriter(); event.getThrowableInformation().getThrowable().printStackTrace( new PrintWriter( errors ) ); final String stacktrace = errors.toString(); for ( final SubutaiErrorEventListener listener : listeners ) { notifierPool.execute( new Runnable() { @Override public void run() { try { listener.onEvent( new SubutaiErrorEvent( event.getTimeStamp(), event.getLoggerName(), event.getRenderedMessage(), stacktrace ) ); } catch ( Exception e ) { } } } ); } } } catch ( Exception e ) { } }  void dispose(); void addListener( SubutaiErrorEventListener listener ); void removeListener( SubutaiErrorEventListener listener ); @Override void close(); @Override boolean requiresLayout(); static final Level MIN_REPORT_LOG_LEVEL; }
@Test public void testAppend() throws Exception { doReturn( SubutaiAppender.MIN_REPORT_LOG_LEVEL ).when( loggingEvent ).getLevel(); doReturn( throwableInformation ).when( loggingEvent ).getThrowableInformation(); doReturn( throwable ).when( throwableInformation ).getThrowable(); subutaiAppender.listeners = Sets.newSet(listener); subutaiAppender.append( loggingEvent ); verify( notifierPool ).execute( isA( Runnable.class ) ); }