Make log displayer work as the help message indicates.
It actually takes an argument for the file you want to read.
I figured this should be fixed after Natalia and I wasted
an hour last night trying to figure out why all the log
files mysteriously looked the same.
Change-Id: I04a5881f484191644c3410f3626e7d6688504c53
diff --git a/aos/linux_code/logging/log_displayer.cc b/aos/linux_code/logging/log_displayer.cc
index 805267c..8141cd4 100644
--- a/aos/linux_code/logging/log_displayer.cc
+++ b/aos/linux_code/logging/log_displayer.cc
@@ -38,7 +38,7 @@
"LEVEL must be DEBUG, INFO, WARNING, ERROR, or FATAL.\n"
" It defaults to INFO.\n"
"\n"
- "TODO(brians) implement the commented out ones and changing FILE\n";
+ "TODO(brians) implement the commented out ones.\n";
void PrintHelpAndExit() {
fprintf(stderr, "Usage: %s %s", program_invocation_name, kArgsHelp);
@@ -135,8 +135,10 @@
}
}
- fprintf(stderr, "displaying down to level %s from file '%s'\n",
- ::aos::logging::log_str(filter_level), filename);
+ if (optind < argc) {
+ // We got a filename.
+ filename = argv[optind++];
+ }
if (optind < argc) {
fprintf(stderr, "non-option ARGV-elements: ");
while (optind < argc) {
@@ -144,7 +146,11 @@
}
}
+ fprintf(stderr, "displaying down to level %s from file '%s'\n",
+ ::aos::logging::log_str(filter_level), filename);
+
int fd = open(filename, O_RDONLY);
+
if (fd == -1) {
PLOG(FATAL, "couldn't open file '%s' for reading", filename);
}