提交 ddef6841 编写于 作者: I Igor Canadi

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
上级 75b59d51
# 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
......
......@@ -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;
......
......@@ -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
......
......@@ -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),
......
......@@ -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());
......
......@@ -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<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);
}
}
......@@ -131,7 +131,7 @@ void Info(const shared_ptr<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);
}
}
......@@ -140,7 +140,7 @@ void Warn(const shared_ptr<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);
}
}
......@@ -149,7 +149,7 @@ void Error(const shared_ptr<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);
}
}
......@@ -158,7 +158,7 @@ void Fatal(const shared_ptr<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);
}
}
......@@ -167,7 +167,7 @@ void Log(const shared_ptr<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);
}
}
......
......@@ -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);
......
......@@ -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),
......
......@@ -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),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册