Skip to content

Commit 33b9ea5

Browse files
committed
Android changes
1 parent c6368f6 commit 33b9ea5

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import io.sentry.SentryExecutorService;
4141
import io.sentry.SentryLevel;
4242
import io.sentry.SentryOptions;
43-
import io.sentry.android.core.AndroidLogger;
4443
import io.sentry.android.core.AndroidProfiler;
4544
import io.sentry.android.core.BuildInfoProvider;
4645
import io.sentry.android.core.InternalSentrySdk;
@@ -87,7 +86,8 @@ public class RNSentryModuleImpl {
8786

8887
public static final String NAME = "RNSentry";
8988

90-
private static final ILogger logger = new AndroidLogger(NAME);
89+
private static final RNSentryLogger rnLogger = new RNSentryLogger();
90+
private static final ILogger logger = rnLogger;
9191
private static final BuildInfoProvider buildInfo = new BuildInfoProvider(logger);
9292
private static final String modulesPath = "modules.json";
9393
private static final Charset UTF_8 = Charset.forName("UTF-8"); // NOPMD - Allow using UTF-8
@@ -170,8 +170,17 @@ public void initNativeReactNavigationNewFrameTracking(Promise promise) {
170170
}
171171

172172
public void initNativeSdk(final ReadableMap rnOptions, Promise promise) {
173+
// Set the React context for the logger so it can forward logs to JS
174+
rnLogger.setReactContext(this.reactApplicationContext);
175+
173176
RNSentryStart.startWithOptions(
174-
getApplicationContext(), rnOptions, getCurrentActivity(), logger);
177+
getApplicationContext(),
178+
rnOptions,
179+
options -> {
180+
// Use our custom logger that forwards to JS
181+
options.setLogger(rnLogger);
182+
},
183+
logger);
175184

176185
promise.resolve(true);
177186
}

packages/core/ios/RNSentryNativeLogsForwarder.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ - (void)configureWithEventEmitter:(RCTEventEmitter *)emitter
3939
}];
4040

4141
// Send a test log to verify the forwarding works
42-
[self forwardLogMessage:@"[Sentry] [info] [0] [RNSentryNativeLogsForwarder] Native log forwarding "
43-
@"configured successfully"];
42+
[self forwardLogMessage:
43+
@"[Sentry] [info] [0] [RNSentryNativeLogsForwarder] Native log forwarding "
44+
@"configured successfully"];
4445
}
4546

4647
- (void)stopForwarding

0 commit comments

Comments
 (0)