pw_log_basic: Make module configurable

Updates pw_log_basic to use the new configuration aproach so projects
can configure log contents.

Change-Id: If7149b5e60d33bed6977b06765f6e1e12222d460
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23200
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Armando Montanez <amontanez@google.com>
diff --git a/pw_log_basic/BUILD b/pw_log_basic/BUILD
index 4b877e7..2c4598d 100644
--- a/pw_log_basic/BUILD
+++ b/pw_log_basic/BUILD
@@ -40,6 +40,7 @@
     name = "pw_log_basic",
     srcs = [
         "log_basic.cc",
+        "pw_log_basic_private/config.h",
     ],
     deps = [
         ":headers",
diff --git a/pw_log_basic/BUILD.gn b/pw_log_basic/BUILD.gn
index 438eac9..5269f09 100644
--- a/pw_log_basic/BUILD.gn
+++ b/pw_log_basic/BUILD.gn
@@ -14,9 +14,17 @@
 
 import("//build_overrides/pigweed.gni")
 
+import("$dir_pw_build/module_config.gni")
 import("$dir_pw_build/target_types.gni")
 import("$dir_pw_docgen/docs.gni")
 
+declare_args() {
+  # The build target that overrides the default configuration options for this
+  # module. This should point to a source set that provides defines through a
+  # public config (which may -include a file or add defines directly).
+  pw_log_basic_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
+}
+
 config("default_config") {
   include_dirs = [ "public" ]
 }
@@ -41,6 +49,7 @@
     "$dir_pw_log:facade",
     dir_pw_string,
     dir_pw_sys_io,
+    pw_log_basic_CONFIG,
   ]
   public = [ "public/pw_log_basic/log_basic.h" ]
 
@@ -51,7 +60,10 @@
     defines += [ "PW_EMOJI=1" ]
   }
 
-  sources = [ "log_basic.cc" ]
+  sources = [
+    "log_basic.cc",
+    "pw_log_basic_private/config.h",
+  ]
 }
 
 pw_doc_group("docs") {
diff --git a/pw_log_basic/log_basic.cc b/pw_log_basic/log_basic.cc
index 18423a3..e480614 100644
--- a/pw_log_basic/log_basic.cc
+++ b/pw_log_basic/log_basic.cc
@@ -19,6 +19,7 @@
 #include <cstring>
 
 #include "pw_log/levels.h"
+#include "pw_log_basic_private/config.h"
 #include "pw_string/string_builder.h"
 #include "pw_sys_io/sys_io.h"
 
@@ -37,16 +38,6 @@
 #define RESET     "\033[0m"
 // clang-format on
 
-#ifndef PW_EMOJI
-#define PW_EMOJI 0
-#endif  // PW_EMOJI
-
-// TODO(pwbug/17): Expose these through the config system.
-#define PW_LOG_SHOW_FILENAME 0
-#define PW_LOG_SHOW_FUNCTION 0
-#define PW_LOG_SHOW_FLAG 0
-#define PW_LOG_SHOW_MODULE 0
-
 namespace pw::log_basic {
 namespace {
 
diff --git a/pw_log_basic/pw_log_basic_private/config.h b/pw_log_basic/pw_log_basic_private/config.h
new file mode 100644
index 0000000..6bb9438
--- /dev/null
+++ b/pw_log_basic/pw_log_basic_private/config.h
@@ -0,0 +1,53 @@
+// Copyright 2020 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+#pragma once
+
+// Replaces log levels and flag presence indicator with emoji.
+#ifndef PW_EMOJI
+#define PW_EMOJI 0
+#endif  // PW_EMOJI
+
+// With all the following flags enabled, log messages look like this:
+//
+// clang-format off
+//  my_file.cc                    :  42 |                Foo | TST | INF  Hello, world!
+//  buggy.cc                      :2145 |    ReadBuggyBuffer |     * ERR  No, BAD!
+//
+// With emoji:
+//  my_file.cc                    :  42 |                Foo | TST    ℹ️  Hello, world!
+//  buggy.cc                      :2145 |    ReadBuggyBuffer |     🚩 ❌  No, BAD!
+// clang-format on
+
+// Prints the name of the file that emitted the log message.
+#ifndef PW_LOG_SHOW_FILENAME
+#define PW_LOG_SHOW_FILENAME 0
+#endif  // PW_LOG_SHOW_FILENAME
+
+// Prints the name of the function that emitted the log message.
+#ifndef PW_LOG_SHOW_FUNCTION
+#define PW_LOG_SHOW_FUNCTION 0
+#endif  // PW_LOG_SHOW_FUNCTION
+
+// Prints an indicator for whether or not there are any active flags for a given
+// log statement.
+#ifndef PW_LOG_SHOW_FLAG
+#define PW_LOG_SHOW_FLAG 0
+#endif  // PW_LOG_SHOW_FLAG
+
+// Prints the module name associated with a log statement. This is provided by
+// defining PW_LOG_MODULE_NAME inside module source files, it is not implied by
+// module structure or file path magic.
+#ifndef PW_LOG_SHOW_MODULE
+#define PW_LOG_SHOW_MODULE 0
+#endif  // PW_LOG_SHOW_MODULE