Switch logv with loglevel to virtual

This commit is contained in:
fyrz 2015-02-01 20:08:19 +01:00
parent aaceef3638
commit cfe8837e43
9 changed files with 12 additions and 1 deletions

View file

@ -17,6 +17,7 @@
### Public API changes ### Public API changes
* Deprecated skip_log_error_on_recovery option * Deprecated skip_log_error_on_recovery option
* Logger method logv with log level parameter is now virtual
### 3.9.0 (12/8/2014) ### 3.9.0 (12/8/2014)

View file

@ -14,6 +14,7 @@ namespace rocksdb {
class CountingLogger : public Logger { class CountingLogger : public Logger {
public: public:
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) override { log_count++; } virtual void Logv(const char* format, va_list ap) override { log_count++; }
size_t log_count; size_t log_count;
}; };

View file

@ -79,6 +79,7 @@ class FakeRandomeAccessFile : public RandomAccessFile {
class DumbLogger : public Logger { class DumbLogger : public Logger {
public: public:
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) { } virtual void Logv(const char* format, va_list ap) { }
virtual size_t GetLogFileSize() const { return 0; } virtual size_t GetLogFileSize() const { return 0; }
}; };

View file

@ -633,7 +633,7 @@ class Logger {
// and format. Any log with level under the internal log level // and format. Any log with level under the internal log level
// of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be // of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be
// printed. // 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", static const char* kInfoLogLevelNames[5] = {"DEBUG", "INFO", "WARN",
"ERROR", "FATAL"}; "ERROR", "FATAL"};
if (log_level < log_level_) { if (log_level < log_level_) {

View file

@ -40,6 +40,7 @@ class AutoRollLogger : public Logger {
ResetLogger(); ResetLogger();
} }
using Logger::Logv;
void Logv(const char* format, va_list ap); void Logv(const char* format, va_list ap);
// Write a header entry to the log. All header information will be written // Write a header entry to the log. All header information will be written

View file

@ -735,6 +735,7 @@ TEST(EnvPosixTest, PosixRandomRWFileTest) {
class TestLogger : public Logger { class TestLogger : public Logger {
public: public:
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) override { virtual void Logv(const char* format, va_list ap) override {
log_count++; log_count++;
@ -808,6 +809,7 @@ TEST(EnvPosixTest, LogBufferTest) {
class TestLogger2 : public Logger { class TestLogger2 : public Logger {
public: public:
explicit TestLogger2(size_t max_log_size) : max_log_size_(max_log_size) {} 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 { virtual void Logv(const char* format, va_list ap) override {
char new_format[2000]; char new_format[2000];
std::fill_n(new_format, sizeof(new_format), '2'); std::fill_n(new_format, sizeof(new_format), '2');

View file

@ -322,6 +322,8 @@ class TestMemLogger : public Logger {
} }
last_flush_micros_ = env_->NowMicros(); last_flush_micros_ = env_->NowMicros();
} }
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) { virtual void Logv(const char* format, va_list ap) {
// We try twice: the first time with a fixed-size stack allocated buffer, // We try twice: the first time with a fixed-size stack allocated buffer,
// and the second time with a much larger dynamically allocated buffer. // and the second time with a much larger dynamically allocated buffer.

View file

@ -36,6 +36,7 @@ class OptionsTest {};
class StderrLogger : public Logger { class StderrLogger : public Logger {
public: public:
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) override { virtual void Logv(const char* format, va_list ap) override {
vprintf(format, ap); vprintf(format, ap);
printf("\n"); printf("\n");

View file

@ -58,6 +58,8 @@ class PosixLogger : public Logger {
} }
last_flush_micros_ = env_->NowMicros(); last_flush_micros_ = env_->NowMicros();
} }
using Logger::Logv;
virtual void Logv(const char* format, va_list ap) { virtual void Logv(const char* format, va_list ap) {
const uint64_t thread_id = (*gettid_)(); const uint64_t thread_id = (*gettid_)();