Permalink
Browse files

o write relative time from startup.

o Write header.
  • Loading branch information...
hzeller committed Oct 6, 2012
1 parent 79d07ba commit 939d805bcbfc1d9c2932e74c0f023b1cdeb88a74
Showing with 16 additions and 2 deletions.
  1. +16 −2 folve-main.cc
View
@@ -55,24 +55,37 @@ static struct FolveRuntime {
// Logger that only prints to stderr; used for
class ReaddirLogger {
public:
+ ReaddirLogger() : start_time_(folve::CurrentTime()) {}
+
+ void WriteInit() {
+ if (!folve_rt.readdir_dump_file) return;
+ fprintf (folve_rt.readdir_dump_file, "%-11s %-8s: <log>\n",
+ "# time", " tid");
+ fflush(folve_rt.readdir_dump_file);
+ }
+
ReaddirLogger &Log(const char *fmt, ...)
__attribute__ ((format (printf, 2, 3))) {
if (!folve_rt.readdir_dump_file) return *this;
- fprintf (folve_rt.readdir_dump_file, "%.6f %08lx: ", folve::CurrentTime(),
- syscall(SYS_gettid));
+ fprintf (folve_rt.readdir_dump_file, "%011.6f %08lx: ",
+ folve::CurrentTime() - start_time_, syscall(SYS_gettid));
va_list ap;
va_start(ap, fmt);
folve::MutexLock l(&io_mutex_);
vfprintf(folve_rt.readdir_dump_file, fmt, ap);
va_end(ap);
return *this;
}
+
void Flush() {
if (folve_rt.readdir_dump_file) {
folve::MutexLock l(&io_mutex_);
fflush(folve_rt.readdir_dump_file);
}
}
+
+private:
+ const double start_time_;
folve::Mutex io_mutex_;
} rlog;
@@ -307,6 +320,7 @@ int FolveOptionHandling(void *data, const char *arg, int key,
return 0;
case FOLVE_OPT_DEBUG_READDIR:
rt->readdir_dump_file = fopen(arg + 2, "w");
+ rlog.WriteInit();
return 0;
case FOLVE_OPT_GAPLESS:
rt->fs->set_gapless_processing(true);

0 comments on commit 939d805

Please sign in to comment.