Log LegacyArchitectureLogger asserts only in Debug mode (#50818)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50818

Logging LegacyArchitectureLogger asserts only in Debug mode as that will give us enough information about wrong usages of Legacy Architecture at this point

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D73322301

fbshipit-source-id: 981a26b1bd7c89080f35ef0ab27677b0a38f2665
This commit is contained in:
David Vacca
2025-04-20 13:44:24 -07:00
committed by Facebook GitHub Bot
parent f98c227ee9
commit 0bdf7bf2c4
@@ -83,14 +83,20 @@ public object LegacyArchitectureLogger {
name: String,
logLevel: LegacyArchitectureLogLevel = LegacyArchitectureLogLevel.WARNING
) {
when (logLevel) {
LegacyArchitectureLogLevel.ERROR -> {
throw AssertionException("$name $exceptionMessage")
}
LegacyArchitectureLogLevel.WARNING -> {
ReactSoftExceptionLogger.logSoftException(
ReactSoftExceptionLogger.Categories.SOFT_ASSERTIONS,
ReactNoCrashSoftException("$name $exceptionMessage"))
// Assert is being reported only in DEBUG mode to prevent over logging in production while we
// we are working on decoupling legacy / new architecture.
// Long term the assert will be executed in production and debug environments.
if (ReactBuildConfig.DEBUG) {
when (logLevel) {
LegacyArchitectureLogLevel.ERROR -> {
throw AssertionException("$name $exceptionMessage")
}
LegacyArchitectureLogLevel.WARNING -> {
ReactSoftExceptionLogger.logSoftException(
ReactSoftExceptionLogger.Categories.SOFT_ASSERTIONS,
ReactNoCrashSoftException("$name $exceptionMessage"))
}
}
}
}