logging: fix unused variable warning in non-debug builds
authorAdam Simpkins <simpkins@fb.com>
Tue, 28 Nov 2017 05:30:58 +0000 (21:30 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 28 Nov 2017 05:35:21 +0000 (21:35 -0800)
Summary:
Use FOLLY_SAFE_DCHECK() rather than assert() to avoid compiler errors about
this variable being unused in builds where assert() statements are disabled.

Reviewed By: bolinfest, yfeldblum

Differential Revision: D6421978

fbshipit-source-id: ab1019fa1fa420856e1bf3bc39c441662c4efd75

folly/experimental/logging/LogConfigParser.cpp

index 7e51472ebf1f4b99179a8357afa56202bc579600..55244207c44cfed344234f7e36a40d2be9e6474e 100644 (file)
@@ -20,6 +20,7 @@
 #include <folly/dynamic.h>
 #include <folly/experimental/logging/LogName.h>
 #include <folly/json.h>
+#include <folly/lang/SafeAssert.h>
 #include <cassert>
 
 using std::shared_ptr;
@@ -330,7 +331,9 @@ LogConfig::CategoryConfigMap parseCategoryConfigs(StringPiece value) {
 
     auto emplaceResult =
         categoryConfigs.emplace(canonicalName, std::move(categoryConfig));
-    assert(emplaceResult.second);
+    FOLLY_SAFE_DCHECK(
+        emplaceResult.second,
+        "category name must be new since it was not in seenCategories");
   }
 
   return categoryConfigs;