From: Adam Simpkins Date: Tue, 28 Nov 2017 20:02:02 +0000 (-0800) Subject: logging: convert assert() checks to FOLLY_SAFE_DCHECK() X-Git-Tag: v2017.12.04.00~26 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d017a3ffa0acf3389a1ee585a035c01cd9e51d07;p=folly.git 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 --- diff --git a/folly/experimental/logging/LogConfigParser.cpp b/folly/experimental/logging/LogConfigParser.cpp index 55244207..d0948709 100644 --- a/folly/experimental/logging/LogConfigParser.cpp +++ b/folly/experimental/logging/LogConfigParser.cpp @@ -21,7 +21,6 @@ #include #include #include -#include 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 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 parseHandlerConfig(StringPiece value) { std::vector 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 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; diff --git a/folly/experimental/logging/test/AsyncFileWriterTest.cpp b/folly/experimental/logging/test/AsyncFileWriterTest.cpp index f2a779a7..753b07e7 100644 --- a/folly/experimental/logging/test/AsyncFileWriterTest.cpp +++ b/folly/experimental/logging/test/AsyncFileWriterTest.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -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;