0

I was surprised to learn that one has to enclose an android logging statement in an

if(DEBUG) {
  Slog.d(...);
}

see https://stackoverflow.com/a/2020964/398348

It is cumbersome.

In the android documentation, it seems to say that one does not have to - the api seems similar to log4j where the log level is configured via external means using a properties file, and only logs above the log level are output.

I would have expected that the implementation of Log.d() would have the if() inside it, so that the developer does not have to enclose it.

class Log {
  void d() {
    if(DEBUG) {....}
  }
...
}

Can someone please clarify?

Note: I do not wish to use proguard as mentioned in several places.

Community
  • 1
  • 1
likejudo
  • 3,396
  • 6
  • 52
  • 107

1 Answers1

0

I use it all the time. Really helps when you publish your application. You really don't want all that logging printing at a production app. By using a simple static boolean DEBUG you can easily turn debugging on and off.

Chris Margonis
  • 935
  • 11
  • 16