From ddef6841b366e6aee1d3a7a175933da1b83e59c0 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Thu, 10 Apr 2014 15:27:42 -0700 Subject: [PATCH] Renamed InfoLogLevel::DEBUG to InfoLogLevel::DEBUG_LEVEL Summary: XCode for some reason injects `#define DEBUG 1` into our code, which makes compile fail because we use `DEBUG` keyword for other stuff. This diff fixes the issue by renaming `DEBUG` to `DEBUG_LEVEL`. Test Plan: compiles Reviewers: dhruba, haobo, sdong, yhchiang, ljin Reviewed By: yhchiang CC: leveldb Differential Revision: https://reviews.facebook.net/D17709 --- HISTORY.md | 5 +++++ db/db_impl.cc | 6 +++--- include/rocksdb/env.h | 14 +++++++------- util/auto_roll_logger.h | 2 +- util/auto_roll_logger_test.cc | 18 +++++++++--------- util/env.cc | 24 ++++++++++++------------ util/env_test.cc | 4 ++-- util/options.cc | 2 +- util/posix_logger.h | 2 +- 9 files changed, 41 insertions(+), 36 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 003313767..53e720351 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,11 @@ # Rocksdb Change Log ## Unreleased (will be released in 3.0) + +### Public API changes +* Added _LEVEL to all InfoLogLevel enums + +### New Features * Column family support ### Public API changes diff --git a/db/db_impl.cc b/db/db_impl.cc index c5caec068..c74cb7531 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1963,7 +1963,7 @@ void DBImpl::BackgroundCallFlush() { DeletionState deletion_state(true); assert(bg_flush_scheduled_); - LogBuffer log_buffer(INFO, options_.info_log.get()); + LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, options_.info_log.get()); { MutexLock l(&mutex_); @@ -2040,7 +2040,7 @@ void DBImpl::BackgroundCallCompaction() { DeletionState deletion_state(true); MaybeDumpStats(); - LogBuffer log_buffer(INFO, options_.info_log.get()); + LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, options_.info_log.get()); { MutexLock l(&mutex_); // Log(options_.info_log, "XXX BG Thread %llx process new work item", @@ -2230,7 +2230,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, } else if (shutting_down_.Acquire_Load()) { // Ignore compaction errors found during shutting down } else { - Log(WARN, options_.info_log, "Compaction error: %s", + Log(InfoLogLevel::WARN_LEVEL, options_.info_log, "Compaction error: %s", status.ToString().c_str()); if (options_.paranoid_checks && bg_error_.ok()) { bg_error_ = status; diff --git a/include/rocksdb/env.h b/include/rocksdb/env.h index b2fe00d25..ce8fe0292 100644 --- a/include/rocksdb/env.h +++ b/include/rocksdb/env.h @@ -535,11 +535,11 @@ class Directory { }; enum InfoLogLevel : unsigned char { - DEBUG = 0, - INFO, - WARN, - ERROR, - FATAL, + DEBUG_LEVEL = 0, + INFO_LEVEL, + WARN_LEVEL, + ERROR_LEVEL, + FATAL_LEVEL, NUM_INFO_LOG_LEVELS, }; @@ -547,7 +547,7 @@ enum InfoLogLevel : unsigned char { class Logger { public: enum { DO_NOT_SUPPORT_GET_LOG_FILE_SIZE = -1 }; - explicit Logger(const InfoLogLevel log_level = InfoLogLevel::INFO) + explicit Logger(const InfoLogLevel log_level = InfoLogLevel::INFO_LEVEL) : log_level_(log_level) {} virtual ~Logger(); @@ -565,7 +565,7 @@ class Logger { return; } - if (log_level == INFO) { + if (log_level == InfoLogLevel::INFO_LEVEL) { // Doesn't print log level if it is INFO level. // This is to avoid unexpected performance regression after we add // the feature of log level. All the logs before we add the feature diff --git a/util/auto_roll_logger.h b/util/auto_roll_logger.h index 4c755f2ab..c592d79ce 100644 --- a/util/auto_roll_logger.h +++ b/util/auto_roll_logger.h @@ -19,7 +19,7 @@ class AutoRollLogger : public Logger { AutoRollLogger(Env* env, const std::string& dbname, const std::string& db_log_dir, size_t log_max_size, size_t log_file_time_to_roll, - const InfoLogLevel log_level = InfoLogLevel::INFO) + const InfoLogLevel log_level = InfoLogLevel::INFO_LEVEL) : Logger(log_level), dbname_(dbname), db_log_dir_(db_log_dir), diff --git a/util/auto_roll_logger_test.cc b/util/auto_roll_logger_test.cc index cbc84d9d0..c49894f59 100755 --- a/util/auto_roll_logger_test.cc +++ b/util/auto_roll_logger_test.cc @@ -74,7 +74,7 @@ void GetFileCreateTime(const std::string& fname, uint64_t* file_ctime) { void AutoRollLoggerTest::RollLogFileBySizeTest(AutoRollLogger* logger, size_t log_max_size, const string& log_message) { - logger->SetInfoLogLevel(InfoLogLevel::INFO); + logger->SetInfoLogLevel(InfoLogLevel::INFO_LEVEL); // measure the size of each message, which is supposed // to be equal or greater than log_message.size() LogMessage(logger, log_message.c_str()); @@ -254,19 +254,19 @@ TEST(AutoRollLoggerTest, InfoLogLevel) { // becomes out of scope. { AutoRollLogger logger(Env::Default(), kTestDir, "", log_size, 0); - for (int log_level = InfoLogLevel::FATAL; log_level >= InfoLogLevel::DEBUG; - log_level--) { + for (int log_level = InfoLogLevel::FATAL_LEVEL; + log_level >= InfoLogLevel::DEBUG_LEVEL; log_level--) { logger.SetInfoLogLevel((InfoLogLevel)log_level); - for (int log_type = InfoLogLevel::DEBUG; log_type <= InfoLogLevel::FATAL; - log_type++) { + for (int log_type = InfoLogLevel::DEBUG_LEVEL; + log_type <= InfoLogLevel::FATAL_LEVEL; log_type++) { // log messages with log level smaller than log_level will not be // logged. LogMessage((InfoLogLevel)log_type, &logger, kSampleMessage.c_str()); } - log_lines += InfoLogLevel::FATAL - log_level + 1; + log_lines += InfoLogLevel::FATAL_LEVEL - log_level + 1; } - for (int log_level = InfoLogLevel::FATAL; log_level >= InfoLogLevel::DEBUG; - log_level--) { + for (int log_level = InfoLogLevel::FATAL_LEVEL; + log_level >= InfoLogLevel::DEBUG_LEVEL; log_level--) { logger.SetInfoLogLevel((InfoLogLevel)log_level); // again, messages with level smaller than log_level will not be logged. @@ -275,7 +275,7 @@ TEST(AutoRollLoggerTest, InfoLogLevel) { Warn(&logger, "%s", kSampleMessage.c_str()); Error(&logger, "%s", kSampleMessage.c_str()); Fatal(&logger, "%s", kSampleMessage.c_str()); - log_lines += InfoLogLevel::FATAL - log_level + 1; + log_lines += InfoLogLevel::FATAL_LEVEL - log_level + 1; } } std::ifstream inFile(AutoRollLoggerTest::kLogFile.c_str()); diff --git a/util/env.cc b/util/env.cc index b7a2a18a2..1c0cae4c3 100644 --- a/util/env.cc +++ b/util/env.cc @@ -44,7 +44,7 @@ void Log(Logger* info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::INFO, format, ap); + info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap); va_end(ap); } } @@ -63,7 +63,7 @@ void Debug(Logger* info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::DEBUG, format, ap); + info_log->Logv(InfoLogLevel::DEBUG_LEVEL, format, ap); va_end(ap); } } @@ -72,7 +72,7 @@ void Info(Logger* info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::INFO, format, ap); + info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap); va_end(ap); } } @@ -81,7 +81,7 @@ void Warn(Logger* info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::WARN, format, ap); + info_log->Logv(InfoLogLevel::WARN_LEVEL, format, ap); va_end(ap); } } @@ -89,7 +89,7 @@ void Error(Logger* info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::ERROR, format, ap); + info_log->Logv(InfoLogLevel::ERROR_LEVEL, format, ap); va_end(ap); } } @@ -97,7 +97,7 @@ void Fatal(Logger* info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::FATAL, format, ap); + info_log->Logv(InfoLogLevel::FATAL_LEVEL, format, ap); va_end(ap); } } @@ -122,7 +122,7 @@ void Debug(const shared_ptr& info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::DEBUG, format, ap); + info_log->Logv(InfoLogLevel::DEBUG_LEVEL, format, ap); va_end(ap); } } @@ -131,7 +131,7 @@ void Info(const shared_ptr& info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::INFO, format, ap); + info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap); va_end(ap); } } @@ -140,7 +140,7 @@ void Warn(const shared_ptr& info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::WARN, format, ap); + info_log->Logv(InfoLogLevel::WARN_LEVEL, format, ap); va_end(ap); } } @@ -149,7 +149,7 @@ void Error(const shared_ptr& info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::ERROR, format, ap); + info_log->Logv(InfoLogLevel::ERROR_LEVEL, format, ap); va_end(ap); } } @@ -158,7 +158,7 @@ void Fatal(const shared_ptr& info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::FATAL, format, ap); + info_log->Logv(InfoLogLevel::FATAL_LEVEL, format, ap); va_end(ap); } } @@ -167,7 +167,7 @@ void Log(const shared_ptr& info_log, const char* format, ...) { if (info_log) { va_list ap; va_start(ap, format); - info_log->Logv(InfoLogLevel::INFO, format, ap); + info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap); va_end(ap); } } diff --git a/util/env_test.cc b/util/env_test.cc index 96c44a1d4..108ad9f81 100644 --- a/util/env_test.cc +++ b/util/env_test.cc @@ -510,7 +510,7 @@ TEST(EnvPosixTest, LogBufferTest) { test_logger.char_x_count = 0; test_logger.char_0_count = 0; LogBuffer log_buffer(INFO, &test_logger); - LogBuffer log_buffer_debug(DEBUG, &test_logger); + LogBuffer log_buffer_debug(DEBUG_LEVEL, &test_logger); char bytes200[200]; std::fill_n(bytes200, sizeof(bytes200), '1'); @@ -529,7 +529,7 @@ TEST(EnvPosixTest, LogBufferTest) { LogToBuffer(&log_buffer, "x%sx%sx", bytes600, bytes9000); LogToBuffer(&log_buffer_debug, "x%sx", bytes200); - test_logger.SetInfoLogLevel(DEBUG); + test_logger.SetInfoLogLevel(DEBUG_LEVEL); LogToBuffer(&log_buffer_debug, "x%sx%sx%sx", bytes600, bytes9000, bytes200); ASSERT_EQ(0, test_logger.log_count); diff --git a/util/options.cc b/util/options.cc index 56a0d43f1..afa9bd8b5 100644 --- a/util/options.cc +++ b/util/options.cc @@ -156,7 +156,7 @@ DBOptions::DBOptions() paranoid_checks(true), env(Env::Default()), info_log(nullptr), - info_log_level(INFO), + info_log_level(INFO_LEVEL), max_open_files(5000), statistics(nullptr), disableDataSync(false), diff --git a/util/posix_logger.h b/util/posix_logger.h index a1086973e..6aba769f1 100644 --- a/util/posix_logger.h +++ b/util/posix_logger.h @@ -39,7 +39,7 @@ class PosixLogger : public Logger { bool flush_pending_; public: PosixLogger(FILE* f, uint64_t (*gettid)(), Env* env, - const InfoLogLevel log_level = InfoLogLevel::ERROR) + const InfoLogLevel log_level = InfoLogLevel::ERROR_LEVEL) : Logger(log_level), file_(f), gettid_(gettid),