diff options
author | Eric Rowe <erowe@google.com> | 2014-10-08 14:56:23 -0700 |
---|---|---|
committer | Eric Rowe <erowe@google.com> | 2014-10-08 14:56:23 -0700 |
commit | 8774acc2ffbd600702c343a5c77f5e01a608f0a9 (patch) | |
tree | 3725ba39104f9107b911c6c52840d668daf9dd48 | |
parent | 57560505cf7012b9783902cb55d143e9bdecd47b (diff) | |
download | loganalysis-8774acc2ffbd600702c343a5c77f5e01a608f0a9.tar.gz |
Add monkey log type to log analyzer
Change-Id: Idcc68cd6e02781647f8ca8e2aa8bee19f5991977
-rw-r--r-- | src/com/android/loganalysis/LogAnalyzer.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/com/android/loganalysis/LogAnalyzer.java b/src/com/android/loganalysis/LogAnalyzer.java index 140ac6d..9275415 100644 --- a/src/com/android/loganalysis/LogAnalyzer.java +++ b/src/com/android/loganalysis/LogAnalyzer.java @@ -19,9 +19,11 @@ import com.android.loganalysis.item.BugreportItem; import com.android.loganalysis.item.IItem; import com.android.loganalysis.item.KernelLogItem; import com.android.loganalysis.item.LogcatItem; +import com.android.loganalysis.item.MonkeyLogItem; import com.android.loganalysis.parser.BugreportParser; import com.android.loganalysis.parser.KernelLogParser; import com.android.loganalysis.parser.LogcatParser; +import com.android.loganalysis.parser.MonkeyLogParser; import com.android.loganalysis.util.config.ArgsOptionParser; import com.android.loganalysis.util.config.ConfigurationException; import com.android.loganalysis.util.config.Option; @@ -54,6 +56,9 @@ public class LogAnalyzer { @Option(name="kernel-log", description="The path to the kernel log") private String mKernelLogPath = null; + @Option(name="monkey-log", description="The path to the monkey log") + private String mMonkeyLogPath = null; + @Option(name="output", description="The output format, currently only JSON") private OutputFormat mOutputFormat = OutputFormat.JSON; @@ -95,6 +100,13 @@ public class LogAnalyzer { printKernelLog(kernelLog); return; } + + if (mMonkeyLogPath != null) { + reader = getBufferedReader(mKernelLogPath); + MonkeyLogItem monkeyLog = new MonkeyLogParser().parse(reader); + printMonkeyLog(monkeyLog); + return; + } } catch (FileNotFoundException e) { System.err.println(e.getMessage()); } catch (IOException e) { @@ -138,6 +150,16 @@ public class LogAnalyzer { } /** + * Print the monkey log to stdout. + */ + private void printMonkeyLog(MonkeyLogItem monkeyLog) { + if (OutputFormat.JSON.equals(mOutputFormat)) { + printJson(monkeyLog); + } + // TODO: Print monkey log in human readable form. + } + + /** * Print an {@link IItem} to stdout. */ private void printJson(IItem item) { @@ -190,6 +212,7 @@ public class LogAnalyzer { if (mBugreportPath != null) logCount++; if (mLogcatPath != null) logCount++; if (mKernelLogPath != null) logCount++; + if (mMonkeyLogPath != null) logCount++; return (logCount == 1); } @@ -197,7 +220,8 @@ public class LogAnalyzer { * Print the usage for the command. */ private void printUsage() { - System.err.println("Usage: loganalysis [--bugreport FILE|--logcat FILE|--kernel-log FILE]"); + System.err.println("Usage: loganalysis [--bugreport FILE | --logcat FILE | " + + "--kernel-log FILE | --monkey-log FILE]"); } /** |