pw_log: Migrate pw_log facade to use link deps like pw_assert

Migrates pw_log to use pw_build_LINK_DEPS w/ require_link_deps.

Updates the upstream log backends to refactor them accordingly.

Also updates the targets to pull in both assert and log through
pw_build_LINK_DEPS.

Note this does not yet move the actual impls, which is blocked by
migrating all users to use pw_build_LINK_DEPS for logging.

Change-Id: I17a4647e2ce2341b8cea6ee5c11cd1227a324c83
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/44147
Reviewed-by: Armando Montanez <amontanez@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
diff --git a/pw_log/BUILD.gn b/pw_log/BUILD.gn
index 913e840..d94926b 100644
--- a/pw_log/BUILD.gn
+++ b/pw_log/BUILD.gn
@@ -34,6 +34,28 @@
     "public/pw_log/short.h",
     "public/pw_log/shorter.h",
   ]
+
+  # TODO(pwbug/372): Update projects to properly list pw_log:impl.
+  # require_link_deps = [ ":impl" ]
+}
+
+# pw_log is low-level and ubiquitous. Because of this, it can often cause
+# circular dependencies. This target collects dependencies from the backend that
+# cannot be used because they would cause circular deps.
+#
+# This group ("$dir_pw_log:impl") must listed in pw_build_LINK_DEPS if
+# pw_log_BACKEND is set.
+#
+# pw_log backends must provide their own "impl" target that collects their
+# actual dependencies. The backend "impl" group may be empty if everything can
+# go directly in the backend target without causing circular dependencies.
+group("impl") {
+  public_deps = []
+
+  if (pw_log_BACKEND != "") {
+    public_deps +=
+        [ get_label_info(pw_log_BACKEND, "label_no_toolchain") + ".impl" ]
+  }
 }
 
 pw_test_group("tests") {