[heap] Move DCHECK from constructor to NewMessageBuilder

The DCHECK is only guaranteed to hold after checking that is_logging()
still returns true.

Bug: v8:10315
Change-Id: Ia43657faffa4c7eda70c95a446bee1389d08e6fd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2418713
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70013}
diff --git a/src/logging/log-utils.cc b/src/logging/log-utils.cc
index 2e5825c..95a551c 100644
--- a/src/logging/log-utils.cc
+++ b/src/logging/log-utils.cc
@@ -79,6 +79,7 @@
   // fine if a background thread starts logging a bit later, but we want to
   // avoid background threads continue logging after logging was already closed.
   if (!logger_->is_logging()) return {};
+  DCHECK_NOT_NULL(format_buffer_.get());
 
   return result;
 }
@@ -98,7 +99,6 @@
 
 Log::MessageBuilder::MessageBuilder(Log* log)
     : log_(log), lock_guard_(&log_->mutex_) {
-  DCHECK_NOT_NULL(log_->format_buffer_.get());
 }
 
 void Log::MessageBuilder::AppendString(String str,