diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/leveldb/env.h | 29 | ||||
-rw-r--r-- | include/leveldb/options.h | 6 |
2 files changed, 26 insertions, 9 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(); diff --git a/include/leveldb/options.h b/include/leveldb/options.h index 0d4f6cd..381f228 100644 --- a/include/leveldb/options.h +++ b/include/leveldb/options.h @@ -12,8 +12,8 @@ namespace leveldb { class Cache; class Comparator; class Env; +class Logger; class Snapshot; -class WritableFile; // DB contents are stored in a set of blocks, each of which holds a // sequence of key,value pairs. Each block may be compressed before @@ -61,10 +61,10 @@ struct Options { Env* env; // Any internal progress/error information generated by the db will - // be to written to info_log if it is non-NULL, or to a file stored + // be written to info_log if it is non-NULL, or to a file stored // in the same directory as the DB contents if info_log is NULL. // Default: NULL - WritableFile* info_log; + Logger* info_log; // ------------------- // Parameters that affect performance |