hotwired / turbo-android

Android framework for making Turbo native apps
MIT License
407 stars 51 forks source link

Improve how debug logging is enabled and how exceptions are logged #287

Closed jayohms closed 10 months ago

jayohms commented 10 months ago

Previously, you needed a TurboSession instance to enable/disable debug logging. However, this was deceiving, since that debug setting was global across all sessions. The change in this PR reflects that debug logging is global across the app and can be set anywhere (ideally once).

Before:

class MainSessionNavHostFragment : TurboSessionNavHostFragment() {

    // ...

    override open fun onSessionCreated() {
        super.onSessionCreated()

        if (BuildConfig.DEBUG) {
          session.setDebugLoggingEnabled(true)
        }
    }

Now:

if (BuildConfig.DEBUG) {
    Turbo.config.debugLoggingEnabled = true
}

Additionally, logged errors now include the exception stacktrace.