Skip to content

Remove logging in release builds or provide facility to do so #17

@trevjonez

Description

@trevjonez

Upon integrating this client SDK I was immediately presented with a gradle error due to mismatch of slf4j versions between app and test apks.
When further inspecting the source I found the majority of the sdk is implemented depending directly on android.util.Log excluding the LDUser class which uses org.slf4j.Logger.
This is troubling at least for me for two reasons, first being that the inclusion of com.noveogroup.android:android-logger as a dependency seems unnecessary given the tiny usage profile.
Second reason being that the logging via android.util.Log is being left in place for all use cases except where removed via a consuming builds proguard config.

It would be preferable to use a smaller footprint android first logging library such as Timber or remove all logging when releasing artifacts by simply wrap all calls to android.util.Log with an if (BuildConfig.LOGGING)and using something like the following in your build.gradle file:

android {
    buildTypes {
        release {
            buildConfigField "boolean", "LOGGING", "false"
        }
        debug {
            buildConfigField "boolean", "LOGGING", "true"
        }
    }
}

This will result in a compile time constant allowing the if block and logging method call to be completely removed by the compiler.
Which may be preferable when compared to BuildConfig.DEBUG which is implemented as a runtime parsed string thus disallowing automatic compile time removal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions