make log_displayer following faster on large files
It can now skip to close to the end of a log file without missing any
struct types. This means following old log files with a new
log_displayer won't work, but that's not very useful anyways...
Change-Id: I8ed78ce0bd0e1d7f28b6e98284490ea9b5a43f1e
diff --git a/aos/linux_code/logging/log_displayer.cc b/aos/linux_code/logging/log_displayer.cc
index 22ea0bd..cdc8f46 100644
--- a/aos/linux_code/logging/log_displayer.cc
+++ b/aos/linux_code/logging/log_displayer.cc
@@ -233,16 +233,20 @@
}
}
- fprintf(stderr, "displaying down to level %s from file '%s'\n",
- ::aos::logging::log_str(filter_level), filename);
-
int fd;
if (strcmp(filename, "-") == 0) {
+ if (skip_to_end) {
+ fputs("Can't skip to end of stdin!\n", stderr);
+ return EXIT_FAILURE;
+ }
fd = STDIN_FILENO;
} else {
fd = open(filename, O_RDONLY);
}
+ fprintf(stderr, "displaying down to level %s from file '%s'\n",
+ ::aos::logging::log_str(filter_level), filename);
+
if (fd == -1) {
PLOG(FATAL, "couldn't open file '%s' for reading", filename);
}
@@ -250,6 +254,7 @@
if (skip_to_end) {
fputs("skipping old logs...\n", stderr);
+ reader.SkipToLastSeekablePage();
}
const LogFileMessageHeader *msg;