Commit d017a3ff authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

logging: convert assert() checks to FOLLY_SAFE_DCHECK()

Summary:
Replace all assert() checks in the folly logging code with
FOLLY_SAFE_DCHECK().

Reviewed By: yfeldblum

Differential Revision: D6422885

fbshipit-source-id: 5cb12dd59f2fe5d346f15b9d317abede8654a879
parent 6e6f346d
......@@ -21,7 +21,6 @@
#include <folly/experimental/logging/LogName.h>
#include <folly/json.h>
#include <folly/lang/SafeAssert.h>
#include <cassert>
using std::shared_ptr;
using std::string;
......@@ -277,8 +276,9 @@ LogConfig::CategoryConfigMap parseCategoryConfigs(StringPiece value) {
// Split the configString into level and handler information.
std::vector<StringPiece> handlerPieces;
folly::split(":", configString, handlerPieces);
// folly::split() always returns a list of length 1
assert(handlerPieces.size() >= 1);
FOLLY_SAFE_DCHECK(
handlerPieces.size() >= 1,
"folly::split() always returns a list of length 1");
auto levelString = trimWhitespace(handlerPieces[0]);
bool hasHandlerConfig = handlerPieces.size() > 1;
......@@ -359,8 +359,8 @@ bool splitNameValue(
std::pair<std::string, LogHandlerConfig> parseHandlerConfig(StringPiece value) {
std::vector<StringPiece> pieces;
folly::split(",", value, pieces);
// "folly::split() always returns a list of length 1";
assert(pieces.size() >= 1);
FOLLY_SAFE_DCHECK(
pieces.size() >= 1, "folly::split() always returns a list of length 1");
StringPiece handlerName;
StringPiece handlerType;
......@@ -419,8 +419,8 @@ LogConfig parseLogConfig(StringPiece value) {
// From then on each section specifies a single LogHandler config.
std::vector<StringPiece> pieces;
folly::split(";", value, pieces);
// "folly::split() always returns a list of length 1";
assert(pieces.size() >= 1);
FOLLY_SAFE_DCHECK(
pieces.size() >= 1, "folly::split() always returns a list of length 1");
auto categoryConfigs = parseCategoryConfigs(pieces[0]);
LogConfig::HandlerConfigMap handlerConfigs;
......
......@@ -29,6 +29,7 @@
#include <folly/futures/Future.h>
#include <folly/futures/Promise.h>
#include <folly/init/Init.h>
#include <folly/lang/SafeAssert.h>
#include <folly/portability/GFlags.h>
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
......@@ -294,7 +295,9 @@ class ReadStats {
}
void writerFinished(size_t threadID, size_t messagesWritten, uint32_t flags) {
auto map = perThreadWriteData_.wlock();
assert(map->find(threadID) == map->end());
FOLLY_SAFE_CHECK(
map->find(threadID) == map->end(),
"multiple writer threads with same ID");
auto& data = (*map)[threadID];
data.numMessagesWritten = messagesWritten;
data.flags = flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment