#include "leveldb/db.h" #include "leveldb/env.h" // 添加对 Env 类的完整定义 #include using namespace std; using namespace leveldb; int main() { DB* db = nullptr; Options op; op.create_if_missing = true; // 创建日志文件并将其关联到 Options 的 info_log Logger* logger; Status log_status = Env::Default()->NewLogger("leveldb_log.txt", &logger); if (log_status.ok()) { op.info_log = logger; // 正确设置 Logger 指针 } else { cerr << "Failed to create logger: " << log_status.ToString() << endl; } Status status = DB::Open(op, "testWAL", &db); assert(status.ok()); db->Put(WriteOptions(), "001", "leveldb"); string s; db->Get(ReadOptions(), "001", &s); cout<Put(WriteOptions(), "002", "world"); string s1; db->Delete(WriteOptions(), "002"); db->Get(ReadOptions(), "002", &s1); cout<