From f5d90be206db98bbd5894afc8d757dd32360b2d9 Mon Sep 17 00:00:00 2001 From: mukesh agrawal Date: Fri, 5 Aug 2016 14:29:30 -0700 Subject: logging: add convenience APIs for literal messages Literal messages are reasonably common, so we should make them easy to log. Add APIs for that purpose, and migrate WifiDiagnostics to use them. Note that, functionally speaking, the LogcatLog implementations of these APIs behave the same their corresponding legacy APIs. However, we add these APIs for two reasons: - To track which log messages have been audited, to determine whether or not they contain parameters. - So that the WifiLog implementation for the new backend can inform the backend that these messages are clean (free of any sensitive data). Finally, we note that these convenience APIs may also provide a performance benefit. (Because the message is parameter-less, there's no need to create a LogMessage.) While there: change the level of some WifiDiagnostics log messages, to fit our new logging guidelines. BUG=30737889 TEST=wifitests/runtests.sh Change-Id: I3d39c1932800af6a818c59b6497c868f8399f8fa --- .../java/com/android/server/wifi/WifiDiagnostics.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'service/java/com/android/server/wifi/WifiDiagnostics.java') diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java index 160cf6bdf..777f46358 100644 --- a/service/java/com/android/server/wifi/WifiDiagnostics.java +++ b/service/java/com/android/server/wifi/WifiDiagnostics.java @@ -154,7 +154,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { } if (!mWifiNative.startPktFateMonitoring()) { - mLog.e("Failed to start packet fate monitoring"); + mLog.wC("Failed to start packet fate monitoring"); } } @@ -163,7 +163,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { if (mPerPacketRingBuffer != null) { startLoggingRingBuffer(mPerPacketRingBuffer); } else { - if (DBG) mLog.d("There is no per packet ring buffer"); + if (DBG) mLog.tC("There is no per packet ring buffer"); } } @@ -172,7 +172,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { if (mPerPacketRingBuffer != null) { stopLoggingRingBuffer(mPerPacketRingBuffer); } else { - if (DBG) mLog.d("There is no per packet ring buffer"); + if (DBG) mLog.tC("There is no per packet ring buffer"); } } @@ -180,9 +180,9 @@ class WifiDiagnostics extends BaseWifiDiagnostics { public synchronized void stopLogging() { if (mIsLoggingEventHandlerRegistered) { if (!mWifiNative.resetLogHandler()) { - mLog.e("Fail to reset log handler"); + mLog.wC("Fail to reset log handler"); } else { - if (DBG) mLog.d("Reset log handler"); + if (DBG) mLog.tC("Reset log handler"); } // Clear mIsLoggingEventHandlerRegistered even if resetLogHandler() failed, because // the log handler is in an indeterminate state. @@ -424,7 +424,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { } } } else { - mLog.e("no ring buffers found"); + mLog.wC("no ring buffers found"); } return mRingBuffers != null; @@ -439,7 +439,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { private boolean startLoggingAllExceptPerPacketBuffers() { if (mRingBuffers == null) { - if (DBG) mLog.d("No ring buffers to log anything!"); + if (DBG) mLog.tC("No ring buffers to log anything!"); return false; } @@ -544,7 +544,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { compressor.end(); bos.close(); } catch (IOException e) { - mLog.e("ByteArrayOutputStream close error"); + mLog.wC("ByteArrayOutputStream close error"); result = android.util.Base64.encodeToString(input, Base64.DEFAULT); return result; } @@ -588,7 +588,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { } private LimitedCircularArray getKernelLog(int maxLines) { - if (DBG) mLog.d("Reading kernel log ..."); + if (DBG) mLog.tC("Reading kernel log ..."); LimitedCircularArray lines = new LimitedCircularArray(maxLines); String log = mWifiNative.readKernelLog(); String logLines[] = log.split("\n"); -- cgit v1.2.3