twotoasters / hoot

A powerful, flexible, lightweight Android library for dealing with RESTful endpoints.
Apache License 2.0
26 stars 10 forks source link

Logging limitations. #5

Open twaddington opened 11 years ago

twaddington commented 11 years ago

So I think it's probably important to wrap any verbose/debug level log calls with controls so they can be disabled. I'm not sure we want our API endpoints printed to the log everytime someone uses the app.

I was thinking you could do something simple like:

if (BuildConfig.DEBUG) {
    Log.d(TAG, "...");
}

We could also do something more complicated like using the Log.isLoggable() method like so:

if (Log.isLoggable(TAG, BuildConfig.DEBUG)) {
    Log.d(TAG, "...");
}

However, this is slightly more confusing and suppresses log levels below INFO by default. Using isLoggable you can set your minimum log level by running the following command from the command-line:

$ adb shell setprop log.tag.Hoot VERBOSE

# List all set log properties
$ adb shell getprop | grep log

Personally I like the first option. Short and sweet. Thoughts?

carltonwhitehead commented 11 years ago

@twaddington, I agree it would be nice to prevent Hoot from logging all this info in release builds without having to make an alteration to Hoot for each project. Unfortunately, it looks like in some cases the BuildConfig.DEBUG will be true even for exported application packages, so I don't want to rely on it here. I have an alternative solution that I will push momentarily.