Permalink
Browse files

Use isLoggable to restrict excess logging at possible hotspot

Note that if you actually *do* want to see these log messages, you need
to use 'adb' to enable the log level:

adb shell setprop log.tag.RTS DEBUG
  • Loading branch information...
1 parent 7eabc03 commit 42b9f6c1c88ae172e8da7a9442c8efae98980f17 @rtyley rtyley committed Mar 19, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 app/src/main/java/com/github/mobile/gauges/realtime/RealtimeTrafficService.java
View
8 app/src/main/java/com/github/mobile/gauges/realtime/RealtimeTrafficService.java
@@ -17,6 +17,8 @@
package com.github.mobile.gauges.realtime;
+import static android.util.Log.DEBUG;
+import static android.util.Log.isLoggable;
import static com.github.mobile.gauges.authenticator.AuthConstants.AUTHTOKEN_TYPE;
import static com.github.mobile.gauges.authenticator.AuthConstants.GAUGES_ACCOUNT_TYPE;
import static java.util.concurrent.Executors.newFixedThreadPool;
@@ -121,8 +123,10 @@ public GaugesService get() {
}
void broadcast(Hit hit, Gauge gauge) {
- long views = gauge.getToday().getViews();
- Log.d(TAG, "Broadcasting '" + gauge.getTitle() + "' views=" + views + " to " + hitListeners.size());
+ if (isLoggable(TAG, DEBUG)) {
+ long views = gauge.getToday().getViews();
+ Log.d(TAG, "Broadcasting '" + gauge.getTitle() + "' views=" + views + " to " + hitListeners.size());
+ }
for (HitListener hitListener : hitListeners.keySet())
hitListener.observe(hit, gauge);
}

0 comments on commit 42b9f6c

Please sign in to comment.