From cfe8837e43cbe05040a6a59ef8760cfb53f83758 Mon Sep 17 00:00:00 2001 From: fyrz Date: Sun, 1 Feb 2015 20:08:19 +0100 Subject: [PATCH] Switch logv with loglevel to virtual --- HISTORY.md | 1 + db/compaction_picker_test.cc | 1 + db/table_properties_collector_test.cc | 1 + include/rocksdb/env.h | 2 +- util/auto_roll_logger.h | 1 + util/env_test.cc | 2 ++ util/mock_env.cc | 2 ++ util/options_test.cc | 1 + util/posix_logger.h | 2 ++ 9 files changed, 12 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 3502df3ea..bef3e1ff1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -17,6 +17,7 @@ ### Public API changes * Deprecated skip_log_error_on_recovery option +* Logger method logv with log level parameter is now virtual ### 3.9.0 (12/8/2014) diff --git a/db/compaction_picker_test.cc b/db/compaction_picker_test.cc index e0ba7722e..ca7ba014f 100644 --- a/db/compaction_picker_test.cc +++ b/db/compaction_picker_test.cc @@ -14,6 +14,7 @@ namespace rocksdb { class CountingLogger : public Logger { public: + using Logger::Logv; virtual void Logv(const char* format, va_list ap) override { log_count++; } size_t log_count; }; diff --git a/db/table_properties_collector_test.cc b/db/table_properties_collector_test.cc index 74abf8670..364b23b44 100644 --- a/db/table_properties_collector_test.cc +++ b/db/table_properties_collector_test.cc @@ -79,6 +79,7 @@ class FakeRandomeAccessFile : public RandomAccessFile { class DumbLogger : public Logger { public: + using Logger::Logv; virtual void Logv(const char* format, va_list ap) { } virtual size_t GetLogFileSize() const { return 0; } }; diff --git a/include/rocksdb/env.h b/include/rocksdb/env.h index 433fa4174..dfc598ff6 100644 --- a/include/rocksdb/env.h +++ b/include/rocksdb/env.h @@ -633,7 +633,7 @@ class Logger { // and format. Any log with level under the internal log level // of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be // printed. - void Logv(const InfoLogLevel log_level, const char* format, va_list ap) { + virtual void Logv(const InfoLogLevel log_level, const char* format, va_list ap) { static const char* kInfoLogLevelNames[5] = {"DEBUG", "INFO", "WARN", "ERROR", "FATAL"}; if (log_level < log_level_) { diff --git a/util/auto_roll_logger.h b/util/auto_roll_logger.h index 4aab6a119..486a1eae3 100644 --- a/util/auto_roll_logger.h +++ b/util/auto_roll_logger.h @@ -40,6 +40,7 @@ class AutoRollLogger : public Logger { ResetLogger(); } + using Logger::Logv; void Logv(const char* format, va_list ap); // Write a header entry to the log. All header information will be written diff --git a/util/env_test.cc b/util/env_test.cc index 351f6358a..9e484c77f 100644 --- a/util/env_test.cc +++ b/util/env_test.cc @@ -735,6 +735,7 @@ TEST(EnvPosixTest, PosixRandomRWFileTest) { class TestLogger : public Logger { public: + using Logger::Logv; virtual void Logv(const char* format, va_list ap) override { log_count++; @@ -808,6 +809,7 @@ TEST(EnvPosixTest, LogBufferTest) { class TestLogger2 : public Logger { public: explicit TestLogger2(size_t max_log_size) : max_log_size_(max_log_size) {} + using Logger::Logv; virtual void Logv(const char* format, va_list ap) override { char new_format[2000]; std::fill_n(new_format, sizeof(new_format), '2'); diff --git a/util/mock_env.cc b/util/mock_env.cc index bcfc611b5..2b357cefe 100644 --- a/util/mock_env.cc +++ b/util/mock_env.cc @@ -322,6 +322,8 @@ class TestMemLogger : public Logger { } last_flush_micros_ = env_->NowMicros(); } + + using Logger::Logv; virtual void Logv(const char* format, va_list ap) { // We try twice: the first time with a fixed-size stack allocated buffer, // and the second time with a much larger dynamically allocated buffer. diff --git a/util/options_test.cc b/util/options_test.cc index 5ddfac27c..0c1e3ce21 100644 --- a/util/options_test.cc +++ b/util/options_test.cc @@ -36,6 +36,7 @@ class OptionsTest {}; class StderrLogger : public Logger { public: + using Logger::Logv; virtual void Logv(const char* format, va_list ap) override { vprintf(format, ap); printf("\n"); diff --git a/util/posix_logger.h b/util/posix_logger.h index e4a2c8456..6faa844ba 100644 --- a/util/posix_logger.h +++ b/util/posix_logger.h @@ -58,6 +58,8 @@ class PosixLogger : public Logger { } last_flush_micros_ = env_->NowMicros(); } + + using Logger::Logv; virtual void Logv(const char* format, va_list ap) { const uint64_t thread_id = (*gettid_)();