fixed struct log stuff
It was writing out the types every time and relying on that behavior.
diff --git a/aos/linux_code/logging/log_displayer.cc b/aos/linux_code/logging/log_displayer.cc
index 7b56f35..98021b5 100644
--- a/aos/linux_code/logging/log_displayer.cc
+++ b/aos/linux_code/logging/log_displayer.cc
@@ -50,11 +50,16 @@
int main(int argc, char **argv) {
const char *filter_name = NULL;
- size_t filter_length;
+ size_t filter_length = 0;
log_level filter_level = INFO;
- bool follow = false, start_at_beginning = true;
+ bool follow = false;
+ // Whether we need to skip everything until we get to the end of the file.
+ bool skip_to_end = false;
const char *filename = "aos_log-current";
+ ::aos::logging::AddImplementation(
+ new ::aos::logging::StreamLogImplementation(stdout));
+
while (true) {
static struct option long_options[] = {
{"name", required_argument, NULL, 'n'},
@@ -100,16 +105,16 @@
break;
case 'f':
follow = true;
- start_at_beginning = false;
+ skip_to_end = true;
break;
case 't':
follow = false;
break;
case 'b':
- start_at_beginning = true;
+ skip_to_end = false;
break;
case 'e':
- start_at_beginning = false;
+ skip_to_end = true;
break;
case 'm':
abort();
@@ -145,8 +150,9 @@
exit(EXIT_FAILURE);
}
::aos::logging::linux_code::LogFileAccessor accessor(fd, false);
- if (!start_at_beginning) {
- accessor.MoveToEnd();
+
+ if (skip_to_end) {
+ fputs("skipping old logs...\n", stderr);
}
const LogFileMessageHeader *msg;
@@ -166,6 +172,15 @@
continue;
}
+ if (skip_to_end) {
+ if (accessor.IsLastPage()) {
+ fputs("done skipping old logs\n", stderr);
+ skip_to_end = false;
+ } else {
+ continue;
+ }
+ }
+
if (::aos::logging::log_gt_important(filter_level, msg->level)) continue;
if (filter_name != NULL) {
if (filter_length != msg->name_size) continue;