I ran aground of this same problem: This is one area where the
documentation appears to be misleading.  The docs for android.util.Log
say:

"Verbose should never be compiled into an application except during
development. Debug logs are compiled in but stripped at runtime.
Error, warning and info logs are always kept."

This implies that somehow Log.d messages are stripped from release
builds.  It also seems to imply that Log.v is never compiled into a
release build. However, after testing this on the G1 I gather that no
Log.foo statement is ever stripped from a release build.

The Log utility is very useful for development and debugging, and I'd
love to see it improved in the future to include some facility for
globally compiling out logging. Something similar to the app-global
static flag Andrew and Hackbod suggested, but a clean part of the Log
interface itself.  Perhaps something like:

Log.startContextLog(Context myContext, int aLogLevel);
...
Log.d(TAG,"blah blah blah");
...
Log.stopContextLog(Context myContext);

I'm not sure what the most elegant interface is, given that you might
call the logger from code that doesn't have a Context reference
available. But from looking at the LogCat output of numerous apps
already shipping in the App Market, it looks like this "dangling
logger" problem plagues many developers.



On Nov 13, 11:51 am, "Andrew Stadler" <[EMAIL PROTECTED]> wrote:
> There are all sorts of bad things an application can do to a device.
> Filling the logs with debug info (which eats up disk space and CPU
> power) is just one of them.  Eclipse or any other SDK or IDE can't
> magically fix application code.
>
> As hackbod mentioned, the best way to do this is to wrap all of your
> logs in something like this:
>
>   if (DEBUG_LOG) {
>       Log.d(TAG, "my log");
>   }
>
> By defining DEBUG_LOG as a static final boolean, you give the compiler
> the ability to remove it entirely, making your shipping .apk smaller
> and faster.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to