diff --git a/sentry-sample/src/main/AndroidManifest.xml b/sentry-sample/src/main/AndroidManifest.xml index 5c6d2b0df..394f9967d 100644 --- a/sentry-sample/src/main/AndroidManifest.xml +++ b/sentry-sample/src/main/AndroidManifest.xml @@ -44,7 +44,7 @@ - + diff --git a/sentry-sample/src/main/java/io/sentry/core/transport/StdoutTransport.java b/sentry-sample/src/main/java/io/sentry/core/transport/StdoutTransport.java new file mode 100644 index 000000000..144b1c306 --- /dev/null +++ b/sentry-sample/src/main/java/io/sentry/core/transport/StdoutTransport.java @@ -0,0 +1,26 @@ +package io.sentry.core.transport; + +import io.sentry.core.ISerializer; +import io.sentry.core.SentryEvent; +import java.io.IOException; +import java.io.PrintWriter; + +public final class StdoutTransport implements ITransport { + + private final ISerializer serializer; + + public StdoutTransport(final ISerializer serializer) { + this.serializer = serializer; + } + + @Override + public TransportResult send(SentryEvent event) throws IOException { + PrintWriter writer = new PrintWriter(System.out); + serializer.serialize(event, writer); + + return TransportResult.success(); + } + + @Override + public void close() throws IOException {} +} diff --git a/sentry-sample/src/main/java/io/sentry/sample/MyApplication.java b/sentry-sample/src/main/java/io/sentry/sample/MyApplication.java index 591e28bde..1b06fae1d 100644 --- a/sentry-sample/src/main/java/io/sentry/sample/MyApplication.java +++ b/sentry-sample/src/main/java/io/sentry/sample/MyApplication.java @@ -2,6 +2,8 @@ import android.app.Application; import android.os.StrictMode; +import io.sentry.android.core.SentryAndroid; +import io.sentry.core.transport.StdoutTransport; import timber.log.Timber; // import io.sentry.android.core.SentryAndroid; @@ -18,14 +20,13 @@ public void onCreate() { // Example how to initialize the SDK manually which allows access to SentryOptions callbacks. // Make sure you disable the auto init via manifest meta-data: io.sentry.auto-init=false - // SentryAndroid.init( - // this, - // options -> { - // options.setBeforeSend(event -> { - // event.setTag("sample-key", "before-send"); - // }); - // options.setAnrTimeoutIntervalMills(2000); - // }); + SentryAndroid.init( + this, + options -> { + if (BuildConfig.DEBUG) { + options.setTransport(new StdoutTransport(options.getSerializer())); + } + }); } private void strictMode() {