fix some logging issue in CTSv2
* change default logging display level to warning
* don't log with device serial as log tag in ResultReporter
Bug: 27557281
Change-Id: I61dcd259bbfdc6564b104344e4fe8eb88264509c
diff --git a/common/host-side/tradefed/res/config/common-compatibility-config.xml b/common/host-side/tradefed/res/config/common-compatibility-config.xml
index 7f3f76a..1b40f16 100644
--- a/common/host-side/tradefed/res/config/common-compatibility-config.xml
+++ b/common/host-side/tradefed/res/config/common-compatibility-config.xml
@@ -17,6 +17,8 @@
<device_recovery class="com.android.tradefed.device.WaitDeviceRecovery" />
<build_provider class="com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider" />
<test class="com.android.compatibility.common.tradefed.testtype.CompatibilityTest" />
- <logger class="com.android.tradefed.log.FileLogger" />
+ <logger class="com.android.tradefed.log.FileLogger">
+ <option name="log-level-display" value="WARN" />
+ </logger>
<result_reporter class="com.android.compatibility.common.tradefed.result.ResultReporter" />
</configuration>
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
index 28596d3..18695fe 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
@@ -127,7 +127,7 @@
long time = System.currentTimeMillis();
String dirSuffix = getDirSuffix(time);
if (mRetrySessionId != null) {
- Log.d(mDeviceSerial, String.format("Retrying session %d", mRetrySessionId));
+ CLog.d("[%s] Retrying session %d", mDeviceSerial, mRetrySessionId);
List<IInvocationResult> results = null;
try {
results = ResultHandler.getResults(mBuildHelper.getResultsDir());
@@ -327,6 +327,7 @@
File resultFile = ResultHandler.writeResults(mBuildHelper.getSuiteName(),
mBuildHelper.getSuiteVersion(), mBuildHelper.getSuitePlan(), mResult,
mResultDir, mStartTime, elapsedTime + mStartTime, mReferenceUrl);
+ logResult("Result saved at: %s", resultFile.getCanonicalPath());
copyDynamicConfigFiles(mBuildHelper.getDynamicConfigFiles(), mResultDir);
copyFormattingFiles(mResultDir);
zipResults(mResultDir);
@@ -336,8 +337,8 @@
fis = new FileInputStream(resultFile);
mLogSaver.saveLogData("log-result", LogDataType.XML, fis);
} catch (IOException ioe) {
- Log.e(mDeviceSerial, "error saving XML with log saver");
- Log.e(mDeviceSerial, ioe);
+ CLog.e("[%s] error saving XML with log saver", mDeviceSerial);
+ CLog.e(ioe);
} finally {
StreamUtil.close(fis);
}
@@ -347,10 +348,12 @@
logResult("Result Server Response: %d",
mUploader.uploadResult(resultFile, mReferenceUrl));
} catch (IOException ioe) {
- Log.e(mDeviceSerial, ioe);
+ CLog.e("[%s] IOException while uploading result.", mDeviceSerial);
+ CLog.e(ioe);
}
}
} catch (IOException | XmlPullParserException e) {
+ CLog.e("[%s] Exception while saving result XML.", mDeviceSerial);
CLog.e(e);
}
}
@@ -477,10 +480,11 @@
}
private void logResult(String format, Object... args) {
+ format = String.format("[%s] %s", mDeviceSerial, format);
if (mQuietOutput) {
CLog.i(format, args);
} else {
- Log.logAndDisplay(LogLevel.INFO, mDeviceSerial, String.format(format, args));
+ CLog.logAndDisplay(LogLevel.INFO, format, args);
}
}
}