Log in debug only?

by Pamplemousse Mk2 » Thu, 30 Jul 2009 16:06:40 GMT


Sponsored Links
 Hello,

I write a lot of logs in my program with the class android.util.Log.
Do the log methods (Log.v(), Log.d(), ...) are executed on the phone?
When my program will be finished, I won't like to see it try to output
logs in the release version.

I have seen that to make a conditional compilation (for Debug/Release
version), I can use a class like this:

public final class Debug {
          //set to false to allow compiler to identify and eliminate
          //unreachable code
          public static final boolean ON = false;
        }

and use if to add debug codes:

if (Debug.ON) {
  // Do debug works...
}

If Debug.ON is false, the compiler removes the unreachable parts of
code, i.e. the ones inside this if. Should I do the same for Log
functions to be able to activate and deactivate them?

Thanks.
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. High performance access on static data: What is your approach?

Marc,

I've filed an internal issue for us to investigate our serialization
performance problems.




How are you parsing the CSV? Are you buffering the input? Any
mechanism that generates many intermediate Strings will be inefficient
on a device.


This is unfortunate, but not too unreasonable. Depending on what
parser you use, XML might need to do as much work as serialization -
reflectively inspecting types and doing proper serialization lifecycle
requires a lot of complex code. I suspect there are still many
opportunities to improve Java serialization here (caching reflected
fields?); I'll investigate.

-- 

2. SensorManager.registerListener gives unexpected results

I'm registering a sensor listener with this line of code.

mSensorManager.registerListener(this,mSensorManager.getDefaultSensor
(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST);

The rate is set to SENSOR_DELAY_FASTEST with the expectation that I
would receive events roughly every 20-30ms. It turns out that I
receive events only every 200-220ms (just now, my event code simply
logcats the system time).

No matter which rate I use, SENSOR_DELAY_NORMAL, SENSOR_DELAY_UI,
SENSOR_DELAY_GAME, or SENSOR_DELAY_FASTEST, I get the same result?

Any ideas to what am I doing wrong?

-- 

3. Video Player from xml list

4. SDK 2.0 Auto Dim Control?

5. can't launch intent + debug problem, Source not found

6. CyanogenMod-4.2.6 is out

7. Eclair Eugene ASOP15