Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added condition wrapper for only R.N vs supported #4447

Conversation

Rolando-Barbella
Copy link
Contributor

Description

Following issue #4445 I added a condition that limits react logger for not supported versions as @d4vidi recommend it

Copy link
Collaborator

@d4vidi d4vidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Rolando-Barbella,
thanks a lot for this request!
It's the right direction, but I was aiming for an if to be implemented under the attach() method (i.e. making the logger a no-op). I will definitely accept and merge that. In any case, why is the condition minor ≥ 71000 and not ≥71?

@Rolando-Barbella
Copy link
Contributor Author

Hi @d4vidi thanks for the feedback, I just updated the branch with the changes, hopefully it makes more sense now

@d4vidi
Copy link
Collaborator

d4vidi commented Apr 12, 2024

@Rolando-Barbella you don't need the isLoggerEnabled toggle. The entire class is a listener which unless registered, it does nothing.

@Rolando-Barbella
Copy link
Contributor Author

@d4vidi sorry, I have little experience with Kotlin, if the logic inside the attach method is not needed, what do you mean by an if to be implemented under the attach() method (i.e. making the logger a no-op) ?

Do you consider something like this?


object ReactMarkersLogger : ReactMarker.MarkerListener {

    fun attach() {
        ReactMarker.addListener(this)
    }

    override fun logMarker(marker: ReactMarkerConstants, p1: String?, p2: Int) {
        val isMarkerValid = when (marker) {
            DOWNLOAD_START,
            DOWNLOAD_END,
            BUILD_REACT_INSTANCE_MANAGER_START,
            BUILD_REACT_INSTANCE_MANAGER_END,
            REACT_BRIDGE_LOADING_START,
            REACT_BRIDGE_LOADING_END,
            REACT_BRIDGELESS_LOADING_START,
            REACT_BRIDGELESS_LOADING_END,
            CREATE_MODULE_START,
            CREATE_MODULE_END,
            NATIVE_MODULE_SETUP_START,
            NATIVE_MODULE_SETUP_END,
            PRE_RUN_JS_BUNDLE_START,
            RUN_JS_BUNDLE_START,
            RUN_JS_BUNDLE_END,
            CONTENT_APPEARED,
            CREATE_CATALYST_INSTANCE_START,
            CREATE_CATALYST_INSTANCE_END,
            DESTROY_CATALYST_INSTANCE_START,
            DESTROY_CATALYST_INSTANCE_END,
            CREATE_REACT_CONTEXT_START,
            CREATE_REACT_CONTEXT_END,
            PROCESS_PACKAGES_START,
            PROCESS_PACKAGES_END -> true
            else -> false
        }

        if (isMarkerValid && ReactNativeInfo.rnVersion().minor >= 71) {
            Log.d("Detox.RNMarker", "$marker ($p1)")
        }
    }
}

Copy link
Collaborator

@d4vidi d4vidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rolando-Barbella check out my suggestion. This is everything you need.

Comment on lines 13 to 17
if (ReactNativeInfo.rnVersion().minor >= 71) {
isLoggerEnabled = true
} else {
ReactMarker.addListener(this)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (ReactNativeInfo.rnVersion().minor >= 71) {
isLoggerEnabled = true
} else {
ReactMarker.addListener(this)
}
if (ReactNativeInfo.rnVersion().minor >= 71) {
ReactMarker.addListener(this)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@d4vidi much simpler approach! I updated the branch, thank you

@d4vidi d4vidi merged commit 2416bd3 into wix:master Apr 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No static field REACT_BRIDGE_LOADING_START of type Lcom/facebook/react/bridge/ReactMarkerConstants
2 participants