RollbarAppender extends AppenderBase<ILoggingEvent> { @Override protected void append(ILoggingEvent event) { if (event.getLoggerName() != null && event.getLoggerName().startsWith(PACKAGE_NAME)) { addWarn("Recursive logging"); return; } IThrowableProxy throwableProxy = event.getThrowableProxy(); ThrowableWrapper rollbarThrowableWrapper = buildRollbarThrowableWrapper(throwableProxy); Map<String, Object> custom = this.buildCustom(event); rollbar.log(rollbarThrowableWrapper, custom, event.getFormattedMessage(), Level.lookupByName(event.getLevel().levelStr), false); } RollbarAppender(Rollbar rollbar);  RollbarAppender(); @Override void start(); @Override void stop(); void setAccessToken(String accessToken); void setCodeVersion(String codeVersion); void setEnabled(boolean enabled); void setEndpoint(String endpoint); void setEnvironment(String environment); void setFramework(String framework); void setLanguage(String language); void setPlatform(String platform); void setStaticContext(String staticContext); void isEnabled(boolean enabled); void setConfigProviderClassName(String configProviderClassName);  }
@Test public void shouldNotLogIfLoggerIsRollbar() { when(event.getLoggerName()).thenReturn("com.rollbar.any"); sut.append(event); verify(rollbar, never()).log(any(ThrowableWrapper.class), ArgumentMatchers.<String, Object>anyMap(), anyString(), any(Level.class), anyBoolean()); }
@Test public void shouldLogEventWhenNoMarker() { when(event.getLoggerName()).thenReturn(LOGGER_NAME); when(event.getThreadName()).thenReturn(THREAD_NAME); when(event.getLevel()).thenReturn(ch.qos.logback.classic.Level.ERROR); when(event.getThrowableProxy()).thenReturn(rootThrowableProxy); when(event.getMDCPropertyMap()).thenReturn(MDC); when(event.getFormattedMessage()).thenReturn(FORMATTED_MESSAGE); when(event.getArgumentArray()).thenReturn(ARGUMENT_ARRAY); sut.append(event); Map<String, Object> expectedCustom = buildExpectedCustom(LOGGER_NAME, new HashMap<String, Object>(MDC), null, THREAD_NAME, ARGUMENT_ARRAY); verify(rollbar).log(rootThrowableWrapper, expectedCustom, FORMATTED_MESSAGE, Level.ERROR, false); }