diff options
Diffstat (limited to 'include/leveldb/env.h')
-rw-r--r-- | include/leveldb/env.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/include/leveldb/env.h b/include/leveldb/env.h index 39f6a1a..bf51008 100644 --- a/include/leveldb/env.h +++ b/include/leveldb/env.h @@ -22,6 +22,7 @@ namespace leveldb { class FileLock; +class Logger; class RandomAccessFile; class SequentialFile; class Slice; @@ -134,8 +135,8 @@ class Env { // same directory. virtual Status GetTestDirectory(std::string* path) = 0; - // Write an entry to the log file with the specified format. - virtual void Logv(WritableFile* log, const char* format, va_list ap) = 0; + // Create and return a log file for storing informational messages. + virtual Status NewLogger(const std::string& fname, Logger** result) = 0; // Returns the number of micro-seconds since some fixed point in time. Only // useful for computing deltas of time. @@ -210,6 +211,22 @@ class WritableFile { void operator=(const WritableFile&); }; +// An interface for writing log messages. +class Logger { + public: + Logger() { } + virtual ~Logger(); + + // Write an entry to the log file with the specified format. + virtual void Logv(const char* format, va_list ap) = 0; + + private: + // No copying allowed + Logger(const Logger&); + void operator=(const Logger&); +}; + + // Identifies a locked file. class FileLock { public: @@ -222,9 +239,9 @@ class FileLock { }; // Log the specified data to *info_log if info_log is non-NULL. -extern void Log(Env* env, WritableFile* info_log, const char* format, ...) +extern void Log(Logger* info_log, const char* format, ...) # if defined(__GNUC__) || defined(__clang__) - __attribute__((__format__ (__printf__, 3, 4))) + __attribute__((__format__ (__printf__, 2, 3))) # endif ; @@ -284,8 +301,8 @@ class EnvWrapper : public Env { virtual Status GetTestDirectory(std::string* path) { return target_->GetTestDirectory(path); } - virtual void Logv(WritableFile* log, const char* format, va_list ap) { - return target_->Logv(log, format, ap); + virtual Status NewLogger(const std::string& fname, Logger** result) { + return target_->NewLogger(fname, result); } uint64_t NowMicros() { return target_->NowMicros(); |