Print contents of a log file. (*func)() is called on every record.
| 52 | |
| 53 | // Print contents of a log file. (*func)() is called on every record. |
| 54 | Status PrintLogContents(Env* env, const std::string& fname, |
| 55 | void (*func)(uint64_t, Slice, WritableFile*), |
| 56 | WritableFile* dst) { |
| 57 | SequentialFile* file; |
| 58 | Status s = env->NewSequentialFile(fname, &file); |
| 59 | if (!s.ok()) { |
| 60 | return s; |
| 61 | } |
| 62 | CorruptionReporter reporter; |
| 63 | reporter.dst_ = dst; |
| 64 | log::Reader reader(file, &reporter, true, 0); |
| 65 | Slice record; |
| 66 | std::string scratch; |
| 67 | while (reader.ReadRecord(&record, &scratch)) { |
| 68 | (*func)(reader.LastRecordOffset(), record, dst); |
| 69 | } |
| 70 | delete file; |
| 71 | return Status::OK(); |
| 72 | } |
| 73 | |
| 74 | // Called on every item found in a WriteBatch. |
| 75 | class WriteBatchItemPrinter : public WriteBatch::Handler { |
no test coverage detected