Back to project page slf4android.
The source code is released under:
MIT License
If you think the Android project slf4android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package pl.brightinventions.slf4android.androidTest; /*w w w. j av a 2s .co m*/ import android.app.Application; import android.test.ActivityInstrumentationTestCase2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.TimeUnit; import pl.brightinventions.slf4android.LoggerConfiguration; import pl.brightinventions.slf4android.NotifyDeveloperHandler; public class NotifyDeveloperHandlerTests extends ActivityInstrumentationTestCase2<TestActivity> { private Logger LOG; private NotifyDeveloperHandler handler; public NotifyDeveloperHandlerTests() { super(TestActivity.class); } @Override protected void setUp() throws Exception { LoggerConfiguration.resetConfigurationToDefault(); LoggerConfiguration configuration = LoggerConfiguration.configuration(); Application targetContext = (Application) getInstrumentation().getTargetContext().getApplicationContext(); handler = configuration.notifyDeveloperHandler(targetContext, "piotr.mionskowski@gmail.com"); configuration.addHandlerToLogger("", handler); LOG = LoggerFactory.getLogger(getClass().getSimpleName()); super.setUp(); } public void test_dont_send_message_with_level_lower_than_error() throws Exception { getActivity(); LOG.warn("Hello"); } public void test_send_message_with_level_error() throws Exception { getActivity(); LOG.warn("Hello"); LOG.error("Send email", new NullPointerException("A test message")); Thread.sleep(TimeUnit.SECONDS.toMillis(15)); } public void test_send_message_with_custom_subject_body_with_level_error() throws Exception{ handler.withSubject("B??d").withBody("Podaj szczeg?y b??du: "); getActivity(); LOG.warn("Hello"); LOG.error("Send email", new NullPointerException("A test message")); Thread.sleep(TimeUnit.SECONDS.toMillis(15)); } }