return "VERBOSE";
} else if (level < LogLevel::WARN) {
return "INFO";
- } else if (level < LogLevel::ERROR) {
+ } else if (level < LogLevel::ERR) {
return "WARNING";
} else if (level < LogLevel::CRITICAL) {
return "ERROR";
namespace folly {
LogCategory::LogCategory(LoggerDB* db)
- : effectiveLevel_{LogLevel::ERROR},
- level_{static_cast<uint32_t>(LogLevel::ERROR)},
+ : effectiveLevel_{LogLevel::ERR},
+ level_{static_cast<uint32_t>(LogLevel::ERR)},
parent_{nullptr},
name_{},
db_{db} {}
// other log libraries that also use ERROR as their log level name (e.g.,
// glog).
ERR = 4000,
-#ifndef ERROR
- ERROR = 4000,
-#endif
CRITICAL = 5000,
}
LoggerDB::LoggerDB() {
- // Create the root log category, and set the level to ERROR by default
+ // Create the root log category, and set the level to ERR by default
auto rootUptr = std::make_unique<LogCategory>(this);
LogCategory* root = rootUptr.get();
auto ret =
loggersByName_.wlock()->emplace(root->getName(), std::move(rootUptr));
DCHECK(ret.second);
- root->setLevelLocked(LogLevel::ERROR, false);
+ root->setLevelLocked(LogLevel::ERR, false);
}
LoggerDB::LoggerDB(TestConstructorArg) : LoggerDB() {}
tid);
EXPECT_EQ(
expected,
- formatMsg(LogLevel::ERROR, "foo\abar\x1btest", "escapes.cpp", 97));
+ formatMsg(LogLevel::ERR, "foo\abar\x1btest", "escapes.cpp", 97));
expected = folly::sformat(
"I0417 13:45:56.123456 {:5d} escapes.cpp:98] foo\\\\bar\"test\n", tid);
EXPECT_EQ(
Logger foo2{&db, "..foo.."};
EXPECT_EQ(foo.getCategory(), foo2.getCategory());
- EXPECT_EQ(LogLevel::ERROR, db.getCategory("")->getLevel());
- EXPECT_EQ(LogLevel::ERROR, db.getCategory("")->getEffectiveLevel());
+ EXPECT_EQ(LogLevel::ERR, db.getCategory("")->getLevel());
+ EXPECT_EQ(LogLevel::ERR, db.getCategory("")->getEffectiveLevel());
EXPECT_EQ(LogLevel::MAX_LEVEL, db.getCategory("foo.bar")->getLevel());
- EXPECT_EQ(LogLevel::ERROR, db.getCategory("foo.bar")->getEffectiveLevel());
+ EXPECT_EQ(LogLevel::ERR, db.getCategory("foo.bar")->getEffectiveLevel());
db.setLevel(".foo", LogLevel::WARN);
EXPECT_EQ(LogLevel::MAX_LEVEL, db.getCategory("foo.bar")->getLevel());
EXPECT_EQ(LogLevel::CRITICAL, noinherit->getEffectiveLevel());
// Modify the root logger's level
- db.setLevel(".", LogLevel::ERROR);
+ db.setLevel(".", LogLevel::ERR);
EXPECT_EQ(LogLevel::MAX_LEVEL, db.getCategory("foo.test.1234")->getLevel());
EXPECT_EQ(
LogLevel::WARN, db.getCategory("foo.test.1234")->getEffectiveLevel());
db.getCategory("foo.test.noinherit")->getEffectiveLevel());
EXPECT_EQ(LogLevel::MAX_LEVEL, db.getCategory("bar.foo.test")->getLevel());
- EXPECT_EQ(
- LogLevel::ERROR, db.getCategory("bar.foo.test")->getEffectiveLevel());
+ EXPECT_EQ(LogLevel::ERR, db.getCategory("bar.foo.test")->getEffectiveLevel());
}
void testNumHandlers(size_t numHandlers) {
// Log a message to a sibling of foobar
Logger siblingLogger{&db, "foo.sibling"};
- FB_LOG(siblingLogger, ERROR, "oh noes");
+ FB_LOG(siblingLogger, ERR, "oh noes");
for (const auto& handler : handlers) {
auto& messages = handler->getMessages();
EXPECT_EQ(2, messages.size());
auto& messages = rootHandler->getMessages();
ASSERT_EQ(3, messages.size());
EXPECT_EQ("oh noes", messages[2].first.getMessage());
- EXPECT_EQ(LogLevel::ERROR, messages[2].first.getLevel());
+ EXPECT_EQ(LogLevel::ERR, messages[2].first.getLevel());
EXPECT_EQ(siblingLogger.getCategory(), messages[2].first.getCategory());
EXPECT_EQ(rootCategory, messages[2].second);
}
EXPECT_EQ(LogLevel::ERR, stringToLogLevel("err"));
EXPECT_EQ(LogLevel::ERR, stringToLogLevel("eRr"));
EXPECT_EQ(LogLevel::ERR, stringToLogLevel("error"));
+ EXPECT_EQ(LogLevel::ERR, stringToLogLevel("ERR"));
EXPECT_EQ(LogLevel::ERR, stringToLogLevel("ERROR"));
EXPECT_EQ(LogLevel::CRITICAL, stringToLogLevel("critical"));
SCOPED_TRACE( \
"input string: \"" + folly::backslashify<std::string>(value) + "\""); \
LogMessage checkMsg{ \
- category, LogLevel::ERROR, __FILE__, __LINE__, std::string{value}}; \
+ category, LogLevel::ERR, __FILE__, __LINE__, std::string{value}}; \
EXPECT_EQ(expected, checkMsg.getMessage()); \
EXPECT_EQ(hasNewlines, checkMsg.containsNewlines()); \
EXPECT_EQ(__FILE__, checkMsg.getFileName()); \
EXPECT_EQ(LogLevel::DBG5, db.getCategory("foo.bar")->getLevel());
EXPECT_EQ(LogLevel::DBG5, db.getCategory("foo.bar")->getEffectiveLevel());
EXPECT_EQ(LogLevel::MAX_LEVEL, db.getCategory("foo")->getLevel());
- EXPECT_EQ(LogLevel::ERROR, db.getCategory("foo")->getEffectiveLevel());
- EXPECT_EQ(LogLevel::ERROR, db.getCategory("")->getLevel());
- EXPECT_EQ(LogLevel::ERROR, db.getCategory("")->getEffectiveLevel());
+ EXPECT_EQ(LogLevel::ERR, db.getCategory("foo")->getEffectiveLevel());
+ EXPECT_EQ(LogLevel::ERR, db.getCategory("")->getLevel());
+ EXPECT_EQ(LogLevel::ERR, db.getCategory("")->getEffectiveLevel());
EXPECT_EQ(LogLevel::MAX_LEVEL, db.getCategory("foo.bar.test")->getLevel());
EXPECT_EQ(
// Log from a sub-category.
Logger subLogger{&db_, "test.foo.bar"};
auto expectedLine = __LINE__ + 1;
- FB_LOG(subLogger, ERROR, "sub-category\nlog message");
+ FB_LOG(subLogger, ERR, "sub-category\nlog message");
auto& messages = handler_->getMessages();
ASSERT_EQ(1, messages.size());
EXPECT_EQ("sub-category\nlog message", messages[0].first.getMessage());
EXPECT_EQ("LoggerTest.cpp", pathBasename(messages[0].first.getFileName()));
EXPECT_EQ(expectedLine, messages[0].first.getLineNumber());
- EXPECT_EQ(LogLevel::ERROR, messages[0].first.getLevel());
+ EXPECT_EQ(LogLevel::ERR, messages[0].first.getLevel());
EXPECT_TRUE(messages[0].first.containsNewlines());
EXPECT_EQ(subLogger.getCategory(), messages[0].first.getCategory());
EXPECT_EQ(logger_.getCategory(), messages[0].second);
Logger footest{&db_, "test.foo.test"};
Logger footest1234{&db_, "test.foo.test.1234"};
Logger other{&db_, "test.other"};
- db_.setLevel("test", LogLevel::ERROR);
+ db_.setLevel("test", LogLevel::ERR);
db_.setLevel("test.foo", LogLevel::DBG2);
db_.setLevel("test.foo.test", LogLevel::DBG7);
auto& messages = handler_->getMessages();
- // test.other's effective level should be ERROR, so a warning
+ // test.other's effective level should be ERR, so a warning
// message to it should be discarded
FB_LOG(other, WARN, "this should be discarded");
ASSERT_EQ(0, messages.size());
messages.clear();
// Bad format arguments should not throw
- FB_LOGF(footest1234, ERROR, "whoops: {}, {}", getValue());
+ FB_LOGF(footest1234, ERR, "whoops: {}, {}", getValue());
ASSERT_EQ(1, messages.size());
EXPECT_EQ(
"error formatting log message: "
Logger footest{&db, "test.foo.test"};
Logger footest1234{&db, "test.foo.test.1234"};
Logger other{&db, "test.other"};
- db.setLevel("test", LogLevel::ERROR);
+ db.setLevel("test", LogLevel::ERR);
db.setLevel("test.foo", LogLevel::DBG2);
db.setLevel("test.foo.test", LogLevel::DBG7);
auto& messages = handler->getMessages();
- // test.other's effective level should be ERROR, so a warning
+ // test.other's effective level should be ERR, so a warning
// message to it should be discarded
FB_LOGC(other, WARN, "this should be discarded: %d", 5);
ASSERT_EQ(0, messages.size());
messages.clear();
// Errors attempting to format the message should not throw
- FB_LOGC(footest1234, ERROR, "width overflow: %999999999999999999999d", 5);
+ FB_LOGC(footest1234, ERR, "width overflow: %999999999999999999999d", 5);
ASSERT_EQ(1, messages.size());
EXPECT_EQ(
"error formatting printf-style log message: "