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
This commit is contained in:
parent
75b59d5146
commit
ddef6841b3
@ -1,6 +1,11 @@
|
|||||||
# Rocksdb Change Log
|
# Rocksdb Change Log
|
||||||
|
|
||||||
## Unreleased (will be released in 3.0)
|
## Unreleased (will be released in 3.0)
|
||||||
|
|
||||||
|
### Public API changes
|
||||||
|
* Added _LEVEL to all InfoLogLevel enums
|
||||||
|
|
||||||
|
### New Features
|
||||||
* Column family support
|
* Column family support
|
||||||
|
|
||||||
### Public API changes
|
### Public API changes
|
||||||
|
@ -1963,7 +1963,7 @@ void DBImpl::BackgroundCallFlush() {
|
|||||||
DeletionState deletion_state(true);
|
DeletionState deletion_state(true);
|
||||||
assert(bg_flush_scheduled_);
|
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_);
|
MutexLock l(&mutex_);
|
||||||
|
|
||||||
@ -2040,7 +2040,7 @@ void DBImpl::BackgroundCallCompaction() {
|
|||||||
DeletionState deletion_state(true);
|
DeletionState deletion_state(true);
|
||||||
|
|
||||||
MaybeDumpStats();
|
MaybeDumpStats();
|
||||||
LogBuffer log_buffer(INFO, options_.info_log.get());
|
LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, options_.info_log.get());
|
||||||
{
|
{
|
||||||
MutexLock l(&mutex_);
|
MutexLock l(&mutex_);
|
||||||
// Log(options_.info_log, "XXX BG Thread %llx process new work item",
|
// 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()) {
|
} else if (shutting_down_.Acquire_Load()) {
|
||||||
// Ignore compaction errors found during shutting down
|
// Ignore compaction errors found during shutting down
|
||||||
} else {
|
} else {
|
||||||
Log(WARN, options_.info_log, "Compaction error: %s",
|
Log(InfoLogLevel::WARN_LEVEL, options_.info_log, "Compaction error: %s",
|
||||||
status.ToString().c_str());
|
status.ToString().c_str());
|
||||||
if (options_.paranoid_checks && bg_error_.ok()) {
|
if (options_.paranoid_checks && bg_error_.ok()) {
|
||||||
bg_error_ = status;
|
bg_error_ = status;
|
||||||
|
@ -535,11 +535,11 @@ class Directory {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum InfoLogLevel : unsigned char {
|
enum InfoLogLevel : unsigned char {
|
||||||
DEBUG = 0,
|
DEBUG_LEVEL = 0,
|
||||||
INFO,
|
INFO_LEVEL,
|
||||||
WARN,
|
WARN_LEVEL,
|
||||||
ERROR,
|
ERROR_LEVEL,
|
||||||
FATAL,
|
FATAL_LEVEL,
|
||||||
NUM_INFO_LOG_LEVELS,
|
NUM_INFO_LOG_LEVELS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -547,7 +547,7 @@ enum InfoLogLevel : unsigned char {
|
|||||||
class Logger {
|
class Logger {
|
||||||
public:
|
public:
|
||||||
enum { DO_NOT_SUPPORT_GET_LOG_FILE_SIZE = -1 };
|
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) {}
|
: log_level_(log_level) {}
|
||||||
virtual ~Logger();
|
virtual ~Logger();
|
||||||
|
|
||||||
@ -565,7 +565,7 @@ class Logger {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_level == INFO) {
|
if (log_level == InfoLogLevel::INFO_LEVEL) {
|
||||||
// Doesn't print log level if it is INFO level.
|
// Doesn't print log level if it is INFO level.
|
||||||
// This is to avoid unexpected performance regression after we add
|
// This is to avoid unexpected performance regression after we add
|
||||||
// the feature of log level. All the logs before we add the feature
|
// 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,
|
AutoRollLogger(Env* env, const std::string& dbname,
|
||||||
const std::string& db_log_dir, size_t log_max_size,
|
const std::string& db_log_dir, size_t log_max_size,
|
||||||
size_t log_file_time_to_roll,
|
size_t log_file_time_to_roll,
|
||||||
const InfoLogLevel log_level = InfoLogLevel::INFO)
|
const InfoLogLevel log_level = InfoLogLevel::INFO_LEVEL)
|
||||||
: Logger(log_level),
|
: Logger(log_level),
|
||||||
dbname_(dbname),
|
dbname_(dbname),
|
||||||
db_log_dir_(db_log_dir),
|
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,
|
void AutoRollLoggerTest::RollLogFileBySizeTest(AutoRollLogger* logger,
|
||||||
size_t log_max_size,
|
size_t log_max_size,
|
||||||
const string& log_message) {
|
const string& log_message) {
|
||||||
logger->SetInfoLogLevel(InfoLogLevel::INFO);
|
logger->SetInfoLogLevel(InfoLogLevel::INFO_LEVEL);
|
||||||
// measure the size of each message, which is supposed
|
// measure the size of each message, which is supposed
|
||||||
// to be equal or greater than log_message.size()
|
// to be equal or greater than log_message.size()
|
||||||
LogMessage(logger, log_message.c_str());
|
LogMessage(logger, log_message.c_str());
|
||||||
@ -254,19 +254,19 @@ TEST(AutoRollLoggerTest, InfoLogLevel) {
|
|||||||
// becomes out of scope.
|
// becomes out of scope.
|
||||||
{
|
{
|
||||||
AutoRollLogger logger(Env::Default(), kTestDir, "", log_size, 0);
|
AutoRollLogger logger(Env::Default(), kTestDir, "", log_size, 0);
|
||||||
for (int log_level = InfoLogLevel::FATAL; log_level >= InfoLogLevel::DEBUG;
|
for (int log_level = InfoLogLevel::FATAL_LEVEL;
|
||||||
log_level--) {
|
log_level >= InfoLogLevel::DEBUG_LEVEL; log_level--) {
|
||||||
logger.SetInfoLogLevel((InfoLogLevel)log_level);
|
logger.SetInfoLogLevel((InfoLogLevel)log_level);
|
||||||
for (int log_type = InfoLogLevel::DEBUG; log_type <= InfoLogLevel::FATAL;
|
for (int log_type = InfoLogLevel::DEBUG_LEVEL;
|
||||||
log_type++) {
|
log_type <= InfoLogLevel::FATAL_LEVEL; log_type++) {
|
||||||
// log messages with log level smaller than log_level will not be
|
// log messages with log level smaller than log_level will not be
|
||||||
// logged.
|
// logged.
|
||||||
LogMessage((InfoLogLevel)log_type, &logger, kSampleMessage.c_str());
|
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;
|
for (int log_level = InfoLogLevel::FATAL_LEVEL;
|
||||||
log_level--) {
|
log_level >= InfoLogLevel::DEBUG_LEVEL; log_level--) {
|
||||||
logger.SetInfoLogLevel((InfoLogLevel)log_level);
|
logger.SetInfoLogLevel((InfoLogLevel)log_level);
|
||||||
|
|
||||||
// again, messages with level smaller than log_level will not be logged.
|
// 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());
|
Warn(&logger, "%s", kSampleMessage.c_str());
|
||||||
Error(&logger, "%s", kSampleMessage.c_str());
|
Error(&logger, "%s", kSampleMessage.c_str());
|
||||||
Fatal(&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());
|
std::ifstream inFile(AutoRollLoggerTest::kLogFile.c_str());
|
||||||
|
24
util/env.cc
24
util/env.cc
@ -44,7 +44,7 @@ void Log(Logger* info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::INFO, format, ap);
|
info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ void Debug(Logger* info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::DEBUG, format, ap);
|
info_log->Logv(InfoLogLevel::DEBUG_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ void Info(Logger* info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::INFO, format, ap);
|
info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void Warn(Logger* info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::WARN, format, ap);
|
info_log->Logv(InfoLogLevel::WARN_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ void Error(Logger* info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::ERROR, format, ap);
|
info_log->Logv(InfoLogLevel::ERROR_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ void Fatal(Logger* info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::FATAL, format, ap);
|
info_log->Logv(InfoLogLevel::FATAL_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ void Debug(const shared_ptr<Logger>& info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::DEBUG, format, ap);
|
info_log->Logv(InfoLogLevel::DEBUG_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ void Info(const shared_ptr<Logger>& info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::INFO, format, ap);
|
info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ void Warn(const shared_ptr<Logger>& info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::WARN, format, ap);
|
info_log->Logv(InfoLogLevel::WARN_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ void Error(const shared_ptr<Logger>& info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::ERROR, format, ap);
|
info_log->Logv(InfoLogLevel::ERROR_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ void Fatal(const shared_ptr<Logger>& info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::FATAL, format, ap);
|
info_log->Logv(InfoLogLevel::FATAL_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ void Log(const shared_ptr<Logger>& info_log, const char* format, ...) {
|
|||||||
if (info_log) {
|
if (info_log) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
info_log->Logv(InfoLogLevel::INFO, format, ap);
|
info_log->Logv(InfoLogLevel::INFO_LEVEL, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ TEST(EnvPosixTest, LogBufferTest) {
|
|||||||
test_logger.char_x_count = 0;
|
test_logger.char_x_count = 0;
|
||||||
test_logger.char_0_count = 0;
|
test_logger.char_0_count = 0;
|
||||||
LogBuffer log_buffer(INFO, &test_logger);
|
LogBuffer log_buffer(INFO, &test_logger);
|
||||||
LogBuffer log_buffer_debug(DEBUG, &test_logger);
|
LogBuffer log_buffer_debug(DEBUG_LEVEL, &test_logger);
|
||||||
|
|
||||||
char bytes200[200];
|
char bytes200[200];
|
||||||
std::fill_n(bytes200, sizeof(bytes200), '1');
|
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, "x%sx%sx", bytes600, bytes9000);
|
||||||
|
|
||||||
LogToBuffer(&log_buffer_debug, "x%sx", bytes200);
|
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);
|
LogToBuffer(&log_buffer_debug, "x%sx%sx%sx", bytes600, bytes9000, bytes200);
|
||||||
|
|
||||||
ASSERT_EQ(0, test_logger.log_count);
|
ASSERT_EQ(0, test_logger.log_count);
|
||||||
|
@ -156,7 +156,7 @@ DBOptions::DBOptions()
|
|||||||
paranoid_checks(true),
|
paranoid_checks(true),
|
||||||
env(Env::Default()),
|
env(Env::Default()),
|
||||||
info_log(nullptr),
|
info_log(nullptr),
|
||||||
info_log_level(INFO),
|
info_log_level(INFO_LEVEL),
|
||||||
max_open_files(5000),
|
max_open_files(5000),
|
||||||
statistics(nullptr),
|
statistics(nullptr),
|
||||||
disableDataSync(false),
|
disableDataSync(false),
|
||||||
|
@ -39,7 +39,7 @@ class PosixLogger : public Logger {
|
|||||||
bool flush_pending_;
|
bool flush_pending_;
|
||||||
public:
|
public:
|
||||||
PosixLogger(FILE* f, uint64_t (*gettid)(), Env* env,
|
PosixLogger(FILE* f, uint64_t (*gettid)(), Env* env,
|
||||||
const InfoLogLevel log_level = InfoLogLevel::ERROR)
|
const InfoLogLevel log_level = InfoLogLevel::ERROR_LEVEL)
|
||||||
: Logger(log_level),
|
: Logger(log_level),
|
||||||
file_(f),
|
file_(f),
|
||||||
gettid_(gettid),
|
gettid_(gettid),
|
||||||
|
Loading…
Reference in New Issue
Block a user