pw_bloat: pull log & assert into BloatThisBinary

Updates the pw::bloat::BloatThisBinary to use logging and asserts
in the implementation of BloatThisBinary to ensure that size
reports do not have to always include them in the base binary.

Change-Id: Ibadccaf627340e9b011ee8242ccac834e46281b4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/38580
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_bloat/BUILD.gn b/pw_bloat/BUILD.gn
index a2ee59c..17d0767 100644
--- a/pw_bloat/BUILD.gn
+++ b/pw_bloat/BUILD.gn
@@ -28,6 +28,10 @@
   public_configs = [ ":default_config" ]
   public = [ "public/pw_bloat/bloat_this_binary.h" ]
   sources = [ "bloat_this_binary.cc" ]
+  deps = [
+    dir_pw_assert,
+    dir_pw_log,
+  ]
 }
 
 pw_source_set("base_main") {
diff --git a/pw_bloat/bloat_this_binary.cc b/pw_bloat/bloat_this_binary.cc
index 5ecd0ba..bf09f22 100644
--- a/pw_bloat/bloat_this_binary.cc
+++ b/pw_bloat/bloat_this_binary.cc
@@ -16,6 +16,10 @@
 
 #include <cstring>
 
+#include "pw_assert/assert.h"
+#include "pw_assert/light.h"
+#include "pw_log/log.h"
+
 namespace pw::bloat {
 
 char* volatile non_optimizable_pointer;
@@ -50,6 +54,14 @@
                kRandomLargeNumber);
 
   *non_optimizable_pointer = std::strlen(non_optimizable_pointer);
+
+  // This code ensures users do not have to pay for the base cost of using
+  // asserts and logging.
+  PW_ASSERT(*non_optimizable_pointer);
+  PW_DASSERT(*non_optimizable_pointer);
+  PW_CHECK_INT_GE(*non_optimizable_pointer, 0, "Ensure this logic stays");
+  PW_DCHECK_INT_GE(*non_optimizable_pointer, 0, "Ensure this logic stays");
+  PW_LOG_INFO("We care about optimizing: %d", *non_optimizable_pointer);
 }
 
 }  // namespace pw::bloat