Move chip::Logging::LogV to platform-specific implementation (#4741)

* Split out logging support methods per platform.

- Removed mutually exclusive `#defines`
- Removed STDIO_WITH_TIMESTAMPS since it is never set/used

* Move all logging logic from support to platform (to make logic consistent). Android remains

* Fix darwin logging file

* Restyle fixes

* Fix chip logging include

* Large refactor for logging: move into separate platform as a stand alone, add dependencies for some sample applications

* Update logic to include openthread config, make sure efr32 compiles

* Fix android logging config

* Fix logging dependencies in tests

* Restyle fixes

* Re-remove retain logging

* Slight doxygen update for logv

* Rename logging from zephyr to nrfconnect to match target platform

* Remove remaining stdio logging link from previous checkins

* Add log include directory to nrfconnect CMakeFiles

* Switch linux logs to go to stdout instead of syslog. This is for CIRQUE and may not be sane.

* Add logging include dir to esp32 component.mk file

* Update based on code review comments

* Updated with source_set support

* Restyle fixes

* Code review update: include LogV as platform/logging/LogV.h

* Remove platform/logging/include from various makefiles

* Also fix android include - missed last time because of quotes used for those includes

* Fix cc13x2_26x2 logging dependency

* Moved efr32 and esp32 logging.cpp back into platform directory ... will look into moving platform-specific logging back one by one

* Moved qpg6100 logging back into platform-specific directory

* Restyle fixes

* Move cc13x2_26x2 logging.cpp back to platform directory

* Move k32w logging back to platform

* Move nrfconnect/Zephyr logging back to platform

* fix dependency typo

* Moved darwin logging into platform

* Moved linux logging back to platform

* Added TODO on chip test logging binding to stdio

* Restyle fixes
diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn
index 9c7046f..894f7fa 100644
--- a/src/platform/BUILD.gn
+++ b/src/platform/BUILD.gn
@@ -215,6 +215,7 @@
       "${chip_root}/src/lib/core",
       "${chip_root}/src/lib/core:chip_config_header",
       "${chip_root}/src/lib/support",
+      "${chip_root}/src/platform/logging:headers",
       "${chip_root}/src/setup_payload",
       "${nlio_root}:nlio",
     ]
@@ -246,6 +247,7 @@
         "cc13x2_26x2/PlatformManagerImpl.h",
         "cc13x2_26x2/SystemPlatformConfig.h",
       ]
+
       if (chip_enable_openthread) {
         public_deps += [
           "${chip_root}/third_party/ti_simplelink_sdk:mbedtls",
@@ -273,6 +275,7 @@
         "Darwin/ConnectivityManagerImpl.cpp",
         "Darwin/ConnectivityManagerImpl.h",
         "Darwin/InetPlatformConfig.h",
+        "Darwin/Logging.cpp",
         "Darwin/PlatformManagerImpl.cpp",
         "Darwin/PlatformManagerImpl.h",
         "Darwin/PosixConfig.cpp",
diff --git a/src/platform/Darwin/Logging.cpp b/src/platform/Darwin/Logging.cpp
new file mode 100644
index 0000000..a9c9f86
--- /dev/null
+++ b/src/platform/Darwin/Logging.cpp
@@ -0,0 +1,64 @@
+/* See Project chip LICENSE file for licensing information. */
+
+#include <platform/logging/LogV.h>
+
+#include <core/CHIPConfig.h>
+
+#include <os/log.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+namespace chip {
+namespace Logging {
+namespace Platform {
+
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
+{
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    int32_t prefixLen = snprintf(formattedMsg, sizeof(formattedMsg), "CHIP: [%s] ", module);
+    if (prefixLen < 0)
+    {
+        // This should not happen
+        return;
+    }
+
+    if (static_cast<size_t>(prefixLen) >= sizeof(formattedMsg))
+    {
+        prefixLen = sizeof(formattedMsg) - 1;
+    }
+
+    vsnprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - static_cast<size_t>(prefixLen), msg, v);
+
+    switch (category)
+    {
+    case kLogCategory_Error:
+        os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_ERROR, "🔴 %{public}s", formattedMsg);
+#if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
+        fprintf(stdout, "\033[1;31m");
+#endif
+        break;
+
+    case kLogCategory_Progress:
+        os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_INFO, "🔵 %{public}s", formattedMsg);
+#if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
+        fprintf(stdout, "\033[0;32m");
+#endif
+        break;
+
+    case kLogCategory_Detail:
+        os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, "🟢 %{public}s", formattedMsg);
+#if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
+        fprintf(stdout, "\033[0;34m");
+#endif
+        break;
+    }
+#if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
+    fprintf(stdout, "%s\033[0m\n", formattedMsg);
+#endif
+}
+
+} // namespace Platform
+} // namespace Logging
+} // namespace chip
diff --git a/src/platform/EFR32/CHIPDevicePlatformConfig.h b/src/platform/EFR32/CHIPDevicePlatformConfig.h
index e387f04..6e1a6ed 100644
--- a/src/platform/EFR32/CHIPDevicePlatformConfig.h
+++ b/src/platform/EFR32/CHIPDevicePlatformConfig.h
@@ -49,14 +49,6 @@
 
 // These are configuration options that are unique to the EFR32 platform.
 // These can be overridden by the application as needed.
-/**
- * @def CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE
- *
- * The maximum size of any log message.
- */
-#ifndef CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE
-#define CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE 150
-#endif // CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE
 
 // -------------- EFR32 NVM3 Storage Configuration -------------
 
diff --git a/src/platform/EFR32/Logging.cpp b/src/platform/EFR32/Logging.cpp
index d5aafef..2b9315e 100644
--- a/src/platform/EFR32/Logging.cpp
+++ b/src/platform/EFR32/Logging.cpp
@@ -1,41 +1,18 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP Authors
- *    Copyright (c) 2019 Nest Labs, Inc.
- *
- *    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
- *
- *        http://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.
- */
+/* See Project CHIP LICENSE file for licensing information. */
+#include <platform/logging/LogV.h>
 
-/**
- *    @file
- *          Provides implementations for the CHIP and LwIP logging
- *          functions on Silicon Labs EFR32 platforms.
- *
- *          Logging should be initialized by a call to efr32LogInit().  A
- *          spooler task is created that sends the logs to the UART.  Log
- *          entries are queued. If the queue is full then by default error
- *          logs wait indefinitely until a slot is available whereas
- *          non-error logs are dropped to avoid delays.
- */
-/* this file behaves like a config.h, comes first */
-#include <platform/internal/CHIPDeviceLayerInternal.h>
+#include <core/CHIPConfig.h>
+#include <platform/CHIPDeviceConfig.h>
 
-#include <support/CodeUtils.h>
-#include <support/logging/CHIPLogging.h>
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#include <openthread/platform/logging.h>
+#endif
 
+#include <FreeRTOS.h>
 #include <queue.h>
 #include <retargetserial.h>
 #include <stdio.h>
+#include <string.h>
 #include <task.h>
 
 // RTT Buffer size and name
@@ -77,10 +54,6 @@
 #define LOG_LWIP "<lwip  > "
 #define LOG_EFR32 "<efr32 > "
 
-using namespace ::chip;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::DeviceLayer::Internal;
-
 static bool sLogInitialized = false;
 #if LOG_RTT_BUFFER_INDEX != 0
 static uint8_t sLogBuffer[LOG_RTT_BUFFER_SIZE];
@@ -134,7 +107,7 @@
 
     va_start(v, aFormat);
 #if EFR32_LOG_ENABLED
-    char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
 
     strcpy(formattedMsg, LOG_EFR32);
     size_t prefixLen = strlen(formattedMsg);
@@ -167,16 +140,17 @@
 
 namespace chip {
 namespace Logging {
+namespace Platform {
 
 /**
  * CHIP log output functions.
  */
-void LogV(uint8_t module, uint8_t category, const char * aFormat, va_list v)
+void LogV(const char * module, uint8_t category, const char * aFormat, va_list v)
 {
 #if EFR32_LOG_ENABLED && _CHIP_USE_LOGGING
     if (IsCategoryEnabled(category))
     {
-        char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
+        char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
         size_t formattedMsgLen;
 
         constexpr size_t maxPrefixLen = chip::Logging::kMaxModuleNameLen + 3;
@@ -199,11 +173,9 @@
         formattedMsgLen = strlen(formattedMsg);
 
         // Form the log prefix, e.g. "[DL] "
-        formattedMsg[formattedMsgLen++] = '[';
-        GetModuleName(formattedMsg + formattedMsgLen, chip::Logging::kMaxModuleNameLen + 1, module);
-        formattedMsgLen                 = strlen(formattedMsg);
-        formattedMsg[formattedMsgLen++] = ']';
-        formattedMsg[formattedMsgLen++] = ' ';
+        snprintf(formattedMsg, sizeof(formattedMsg), "[%s] ", module);
+        formattedMsg[sizeof(formattedMsg) - 1] = 0;
+        formattedMsgLen                        = strlen(formattedMsg);
 
         size_t len = vsnprintf(formattedMsg + formattedMsgLen, sizeof formattedMsg - formattedMsgLen, aFormat, v);
 
@@ -216,10 +188,11 @@
     }
 
     // Let the application know that a log message has been emitted.
-    DeviceLayer::OnLogOutput();
+    chip::DeviceLayer::OnLogOutput();
 #endif // EFR32_LOG_ENABLED && _CHIP_USE_LOGGING
 }
 
+} // namespace Platform
 } // namespace Logging
 } // namespace chip
 
@@ -232,7 +205,7 @@
 
     va_start(v, aFormat);
 #if EFR32_LOG_ENABLED
-    char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
 
     strcpy(formattedMsg, LOG_LWIP);
     size_t prefixLen = strlen(formattedMsg);
@@ -252,7 +225,7 @@
 #endif
 
     // Let the application know that a log message has been emitted.
-    DeviceLayer::OnLogOutput();
+    chip::DeviceLayer::OnLogOutput();
 #endif // EFR32_LOG_ENABLED
     va_end(v);
 }
@@ -263,12 +236,12 @@
 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
 extern "C" void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ...)
 {
-    IgnoreUnusedVariable(aLogRegion);
+    (void) aLogRegion;
     va_list v;
 
     va_start(v, aFormat);
 #if EFR32_LOG_ENABLED
-    char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
 
     if (sLogInitialized)
     {
@@ -312,11 +285,11 @@
     }
 
     // Let the application know that a log message has been emitted.
-    DeviceLayer::OnLogOutput();
+    chip::DeviceLayer::OnLogOutput();
 #endif // EFR32_LOG_ENABLED
     va_end(v);
 }
-#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#endif // CHIP_ENABLE_OPENTHREAD
 
 #if HARD_FAULT_LOG_ENABLE && EFR32_LOG_ENABLED
 
diff --git a/src/platform/ESP32/Logging.cpp b/src/platform/ESP32/Logging.cpp
index 060731c..d79f630 100644
--- a/src/platform/ESP32/Logging.cpp
+++ b/src/platform/ESP32/Logging.cpp
@@ -1,31 +1,11 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP Authors
- *    Copyright (c) 2018 Nest Labs, Inc.
- *    All rights reserved.
- *
- *    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
- *
- *        http://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.
- */
+/* See Project CHIP LICENSE file for licensing information. */
 
-/**
- *    @file
- *          Provides implementations for the CHIP logging functions
- *          on the ESP32 platform.
- */
-/* this file behaves like a config.h, comes first */
-#include <platform/internal/CHIPDeviceLayerInternal.h>
+#include <platform/logging/LogV.h>
 
-#include <support/logging/CHIPLogging.h>
+#include <core/CHIPConfig.h>
+#include <support/logging/Constants.h>
+
+#include <stdio.h>
 
 #ifdef LOG_LOCAL_LEVEL
 #undef LOG_LOCAL_LEVEL
@@ -34,49 +14,35 @@
 
 #include "esp_log.h"
 
-using namespace ::chip;
-using namespace ::chip::DeviceLayer::Internal;
-
 namespace chip {
 namespace Logging {
+namespace Platform {
 
-void LogV(uint8_t module, uint8_t category, const char * msg, va_list v)
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
 {
-    if (IsCategoryEnabled(category))
+    char tag[11];
+
+    snprintf(tag, sizeof(tag), "chip[%s]", module);
+    tag[sizeof(tag) - 1] = 0;
+
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v);
+
+    switch (category)
     {
-        enum
-        {
-            kMaxTagLen = 7 + chip::Logging::kMaxModuleNameLen
-        };
-        char tag[kMaxTagLen + 1];
-        size_t tagLen;
-        char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
-
-        strcpy(tag, "chip[");
-        tagLen = strlen(tag);
-        GetModuleName(tag + tagLen, chip::Logging::kMaxModuleNameLen + 1, module);
-        tagLen        = strlen(tag);
-        tag[tagLen++] = ']';
-        tag[tagLen]   = 0;
-
-        vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v);
-
-        switch (category)
-        {
-        case kLogCategory_Error:
-            ESP_LOGE(tag, "%s", formattedMsg);
-            break;
-        case kLogCategory_Progress:
-        default:
-            ESP_LOGI(tag, "%s", formattedMsg);
-            break;
-        case kLogCategory_Detail:
-            ESP_LOGV(tag, "%s", formattedMsg);
-            break;
-        }
+    case kLogCategory_Error:
+        ESP_LOGE(tag, "%s", formattedMsg);
+        break;
+    case kLogCategory_Progress:
+    default:
+        ESP_LOGI(tag, "%s", formattedMsg);
+        break;
+    case kLogCategory_Detail:
+        ESP_LOGV(tag, "%s", formattedMsg);
+        break;
     }
 }
 
+} // namespace Platform
 } // namespace Logging
-
 } // namespace chip
diff --git a/src/platform/K32W/Logging.cpp b/src/platform/K32W/Logging.cpp
index 3dda51e..b32d5b5 100644
--- a/src/platform/K32W/Logging.cpp
+++ b/src/platform/K32W/Logging.cpp
@@ -1,34 +1,15 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP Authors
- *    Copyright (c) 2020 Nest Labs, Inc.
- *
- *    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
- *
- *        http://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.
- */
+/* See Project CHIP LICENSE file for licensing information. */
 
-/**
- *    @file
- *          Provides implementations for the CHIP and LwIP logging
- *          functions on NXP K32W platforms.
- */
+#include <platform/logging/LogV.h>
+
+#include <core/CHIPConfig.h>
+#include <platform/CHIPDeviceConfig.h>
+#include <support/logging/Constants.h>
 
 #define K32W_LOG_MODULE_NAME chip
 #define EOL_CHARS "\r\n" /* End of Line Characters */
 #define EOL_CHARS_LEN 2  /* Length of EOL */
 
-#include <platform/internal/CHIPDeviceLayerInternal.h>
-#include <support/logging/CHIPLogging.h>
-
 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
 #include <openthread/platform/logging.h>
 #include <openthread/platform/uart.h>
@@ -36,10 +17,6 @@
 
 extern "C" void K32WWriteBlocking(const uint8_t * aBuf, uint32_t len);
 
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::DeviceLayer::Internal;
-using namespace ::chip::Logging;
-
 void GetMessageString(char * buf, uint8_t chipCategory, uint8_t otLevelLog)
 {
     if (chipCategory != kLogCategory_None)
@@ -81,22 +58,10 @@
     }
 }
 
-void FillPrefix(char * buf, uint8_t bufLen, uint8_t chipCategory, uint8_t otLevelLog, uint8_t module)
+void FillPrefix(char * buf, uint8_t bufLen, uint8_t chipCategory, uint8_t otLevelLog)
 {
-    size_t prefixLen;
-
     /* add the error string */
-    VerifyOrDie(bufLen > chip::Logging::kMaxPrefixLen);
     ::GetMessageString(buf, chipCategory, otLevelLog);
-
-    /* add the module name string */
-    prefixLen = strlen(buf);
-    VerifyOrDie(bufLen > (prefixLen + chip::Logging::kMaxModuleNameLen + 3));
-    buf[prefixLen++] = '[';
-    GetModuleName(buf + prefixLen, chip::Logging::kMaxModuleNameLen + 1, module);
-    prefixLen        = strlen(buf);
-    buf[prefixLen++] = ']';
-    buf[prefixLen++] = ' ';
 }
 
 namespace chip {
@@ -118,17 +83,15 @@
 
 #if K32W_LOG_ENABLED
 
-    char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE - 1] = { 0 };
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE - 1] = { 0 };
     size_t prefixLen, writtenLen;
 
     /* Prefix is composed of [Debug String][MOdule Name String] */
-    FillPrefix(formattedMsg, CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE - 1, kLogCategory_None, kLogCategory_Detail,
-               (uint8_t) kLogModule_NotSpecified);
+    FillPrefix(formattedMsg, CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE - 1, kLogCategory_None, kLogCategory_Detail);
     prefixLen = strlen(formattedMsg);
 
     // Append the log message.
-    writtenLen =
-        vsnprintf(formattedMsg + prefixLen, CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE - prefixLen - EOL_CHARS_LEN, format, arg);
+    writtenLen = vsnprintf(formattedMsg + prefixLen, CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE - prefixLen - EOL_CHARS_LEN, format, arg);
     VerifyOrDie(writtenLen > 0);
     memcpy(formattedMsg + prefixLen + writtenLen, EOL_CHARS, EOL_CHARS_LEN);
 
@@ -146,20 +109,13 @@
 /**
  * CHIP log output function.
  */
-void LogV(uint8_t module, uint8_t category, const char * msg, va_list v)
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
 {
     (void) module;
     (void) category;
 
 #if K32W_LOG_ENABLED
-
-    if (IsCategoryEnabled(category))
-    {
-        {
-            GenericLog(msg, v);
-        }
-    }
-
+    GenericLog(msg, v);
     // Let the application know that a log message has been emitted.
     DeviceLayer::OnLogOutput();
 
diff --git a/src/platform/Linux/Logging.cpp b/src/platform/Linux/Logging.cpp
index 1b351c5..fd693ce 100644
--- a/src/platform/Linux/Logging.cpp
+++ b/src/platform/Linux/Logging.cpp
@@ -1,37 +1,8 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP Authors
- *    Copyright (c) 2018 Nest Labs, Inc.
- *
- *    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
- *
- *        http://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.
- */
+/* See Project CHIP LICENSE file for licensing information. */
 
-/**
- *    @file
- *          Provides implementations for the CHIP and LwIP logging functions
- *          on Linux platforms.
- */
+#include <platform/logging/LogV.h>
 
-#include <platform/internal/CHIPDeviceLayerInternal.h>
-#include <support/logging/CHIPLogging.h>
-
-#include <assert.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-using namespace ::chip;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::DeviceLayer::Internal;
+#include <stdio.h>
 
 namespace chip {
 namespace DeviceLayer {
@@ -45,24 +16,23 @@
 void __attribute__((weak)) OnLogOutput() {}
 
 } // namespace DeviceLayer
-} // namespace chip
 
-namespace chip {
 namespace Logging {
+namespace Platform {
 
 /**
  * CHIP log output functions.
  */
-void LogV(uint8_t module, uint8_t category, const char * msg, va_list v)
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
 {
-    if (IsCategoryEnabled(category))
-    {
-        vsyslog(LOG_INFO, msg, v);
+    printf("CHIP:%s: ", module);
+    vprintf(msg, v);
+    printf("\n");
 
-        // Let the application know that a log message has been emitted.
-        DeviceLayer::OnLogOutput();
-    }
+    // Let the application know that a log message has been emitted.
+    DeviceLayer::OnLogOutput();
 }
 
+} // namespace Platform
 } // namespace Logging
 } // namespace chip
diff --git a/src/platform/Zephyr/Logging.cpp b/src/platform/Zephyr/Logging.cpp
index de5e9d5..0627efc 100644
--- a/src/platform/Zephyr/Logging.cpp
+++ b/src/platform/Zephyr/Logging.cpp
@@ -1,38 +1,15 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP 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
- *
- *        http://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.
- */
+/* See Project CHIP LICENSE file for licensing information. */
 
-/**
- *    @file
- *          Provides implementations for the CHIP logging functions
- *          on Zephyr platforms.
- */
+#include <platform/logging/LogV.h>
 
-#include <platform/internal/CHIPDeviceLayerInternal.h>
-#include <support/logging/CHIPLogging.h>
+#include <core/CHIPConfig.h>
+#include <support/logging/Constants.h>
 
 #include <kernel.h>
 #include <logging/log.h>
 
 #include <cstdio>
 
-using namespace ::chip;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::DeviceLayer::Internal;
-
 LOG_MODULE_REGISTER(chip, LOG_LEVEL_DBG);
 
 namespace chip {
@@ -49,63 +26,53 @@
 } // namespace DeviceLayer
 
 namespace Logging {
+namespace Platform {
 
 /**
  * CHIP log output function.
  */
 
-void LogV(uint8_t module, uint8_t category, const char * msg, va_list v)
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
 {
-    if (!IsCategoryEnabled(category))
-        return;
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
 
-    {
-        char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
-        size_t prefixLen = 0;
+    snprintf(formattedMsg, sizeof(formattedMsg), "%u [%s]", k_uptime_get_32(), module);
 
-        // Max size for "[TAG] {UINT32}"
-        constexpr size_t maxPrefixLen = chip::Logging::kMaxModuleNameLen + 10 + 3;
-        static_assert(sizeof(formattedMsg) > maxPrefixLen);
+    // -2 to ensure at least one byte available for vsnprintf below.
+    formattedMsg[sizeof(formattedMsg) - 2] = 0;
 
-        prefixLen += snprintf(formattedMsg, sizeof(formattedMsg), "%u", k_uptime_get_32());
+    size_t prefixLen = strlen(formattedMsg);
 
-        // Form the log prefix, e.g. "[DL] "
-        formattedMsg[prefixLen++] = '[';
-        GetModuleName(formattedMsg + prefixLen, chip::Logging::kMaxModuleNameLen + 1, module);
-        prefixLen                 = strlen(formattedMsg);
-        formattedMsg[prefixLen++] = ']';
-        formattedMsg[prefixLen++] = ' ';
+    // Append the log message.
+    vsnprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - prefixLen, msg, v);
 
-        // Append the log message.
-        vsnprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - prefixLen, msg, v);
-
-        // Invoke the Zephyr logging library to log the message.
-        //
-        // Unfortunately the Zephyr logging macros end up assigning uint16_t
-        // variables to uint16_t:10 fields, which triggers integer conversion
-        // warnings.  And treating the Zephyr headers as system headers does not
-        // help, apparently.  Just turn off that warning around this switch.
+    // Invoke the Zephyr logging library to log the message.
+    //
+    // Unfortunately the Zephyr logging macros end up assigning uint16_t
+    // variables to uint16_t:10 fields, which triggers integer conversion
+    // warnings.  And treating the Zephyr headers as system headers does not
+    // help, apparently.  Just turn off that warning around this switch.
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wconversion"
-        switch (category)
-        {
-        case kLogCategory_Error:
-            LOG_ERR("%s", log_strdup(formattedMsg));
-            break;
-        case kLogCategory_Progress:
-        default:
-            LOG_INF("%s", log_strdup(formattedMsg));
-            break;
-        case kLogCategory_Detail:
-            LOG_DBG("%s", log_strdup(formattedMsg));
-            break;
-        }
-#pragma GCC diagnostic pop
+    switch (category)
+    {
+    case kLogCategory_Error:
+        LOG_ERR("%s", log_strdup(formattedMsg));
+        break;
+    case kLogCategory_Progress:
+    default:
+        LOG_INF("%s", log_strdup(formattedMsg));
+        break;
+    case kLogCategory_Detail:
+        LOG_DBG("%s", log_strdup(formattedMsg));
+        break;
     }
+#pragma GCC diagnostic pop
 
     // Let the application know that a log message has been emitted.
     DeviceLayer::OnLogOutput();
 }
 
+} // namespace Platform
 } // namespace Logging
 } // namespace chip
diff --git a/src/platform/cc13x2_26x2/Logging.cpp b/src/platform/cc13x2_26x2/Logging.cpp
index e322508..668040a 100644
--- a/src/platform/cc13x2_26x2/Logging.cpp
+++ b/src/platform/cc13x2_26x2/Logging.cpp
@@ -1,45 +1,18 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP Authors
- *    Copyright (c) 2020 Texas Instruments Incorporated
- *
- *    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
- *
- *        http://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.
- */
+/* See Project CHIP LICENSE file for licensing information. */
 
-/**
- *    @file
- *          Provides implementations for the CHIP and LwIP logging functions
- *          for the Texas Instruments CC1352 platform. This uses one of the
- *          UARTs configured with SysConfig. Future implementations may use
- *          ITM.
- *
- */
+#include <platform/logging/LogV.h>
+
+#include <core/CHIPConfig.h>
+#include <platform/CHIPDeviceConfig.h>
 
 #include "ti_drivers_config.h"
-#include <platform/internal/CHIPDeviceLayerInternal.h>
-#include <support/logging/CHIPLogging.h>
 
 #include <ti/drivers/UART.h>
 
 #include <stdio.h>
 
-using namespace ::chip;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::DeviceLayer::Internal;
-
-#define DEVICE_LAYER_LOG_BUFFER_SIZE (256)
 UART_Handle sDebugUartHandle;
-char sDebugUartBuffer[DEVICE_LAYER_LOG_BUFFER_SIZE];
+char sDebugUartBuffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
 
 extern "C" int cc13x2_26x2LogInit(void)
 {
@@ -89,8 +62,9 @@
 
 namespace chip {
 namespace Logging {
+namespace Platform {
 
-void LogV(uint8_t module, uint8_t category, const char * msg, va_list v)
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
 {
     (void) module;
     (void) category;
@@ -100,6 +74,7 @@
     DeviceLayer::OnLogOutput();
 }
 
+} // namespace Platform
 } // namespace Logging
 } // namespace chip
 
@@ -148,4 +123,4 @@
     DeviceLayer::OnLogOutput();
     va_end(v);
 }
-#endif
+#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
diff --git a/src/platform/logging/BUILD.gn b/src/platform/logging/BUILD.gn
new file mode 100644
index 0000000..bfece14
--- /dev/null
+++ b/src/platform/logging/BUILD.gn
@@ -0,0 +1,36 @@
+# See Project CHIP LICENSE file for licensing information.
+
+import("//build_overrides/build.gni")
+import("//build_overrides/chip.gni")
+import("//build_overrides/pigweed.gni")
+
+import("${chip_root}/src/platform/device.gni")
+
+source_set("headers") {
+  public = [ "LogV.h" ]
+}
+
+if (current_os == "android") {
+  static_library("android") {
+    sources = [ "impl/android/Logging.cpp" ]
+    deps = [
+      ":headers",
+      "${chip_root}/src/lib/core:chip_config_header",
+      "${chip_root}/src/lib/support:logging_constants",
+      "${chip_root}/src/platform:platform_buildconfig",
+    ]
+
+    libs = [ "log" ]
+  }
+}
+
+static_library("stdio") {
+  sources = [ "impl/stdio/Logging.cpp" ]
+
+  deps = [
+    ":headers",
+    "${chip_root}/src/lib/core:chip_config_header",
+    "${chip_root}/src/lib/support:logging_constants",
+    "${chip_root}/src/platform:platform_buildconfig",
+  ]
+}
diff --git a/src/platform/logging/LogV.h b/src/platform/logging/LogV.h
new file mode 100644
index 0000000..5b961b7
--- /dev/null
+++ b/src/platform/logging/LogV.h
@@ -0,0 +1,34 @@
+/* See Project CHIP LICENSE file for licensing information. */
+
+#pragma once
+
+#include <stdarg.h>
+#include <stdint.h>
+
+namespace chip {
+namespace Logging {
+namespace Platform {
+
+/**
+ * Log, to the platform-specified mechanism, the specified log
+ * message, @a msg, for the specified module, @a module, in the
+ * provided category, @a category.
+ *
+ * @param[in] module    The name of the log module.
+ * @param[in] category  A LogCategory enumeration indicating the
+ *                      category of the log message. The category
+ *                      may be filtered in or out if
+ *                      CHIP_LOG_FILTERING was asserted.
+ * @param[in] msg       A pointer to a NULL-terminated C string with
+ *                      C Standard Library-style format specifiers
+ *                      containing the log message to be formatted and
+ *                      logged.
+ * @param[in] v         A variadic argument list whose elements should
+ *                      correspond to the format specifiers in @a msg.
+ *
+ */
+void LogV(const char * module, uint8_t category, const char * msg, va_list v);
+
+} // namespace Platform
+} // namespace Logging
+} // namespace chip
diff --git a/src/platform/logging/impl/android/Logging.cpp b/src/platform/logging/impl/android/Logging.cpp
new file mode 100644
index 0000000..932b1a5
--- /dev/null
+++ b/src/platform/logging/impl/android/Logging.cpp
@@ -0,0 +1,20 @@
+/* See Project chip LICENSE file for licensing information. */
+
+#include "platform/logging/LogV.h"
+#include "support/logging/Constants.h"
+
+#include <android/log.h>
+
+namespace chip {
+namespace Logging {
+namespace Platform {
+
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
+{
+    int priority = (category == kLogCategory_Error) ? ANDROID_LOG_ERROR : ANDROID_LOG_DEBUG;
+    __android_log_vprint(priority, module, msg, v);
+}
+
+} // namespace Platform
+} // namespace Logging
+} // namespace chip
diff --git a/src/platform/logging/impl/stdio/Logging.cpp b/src/platform/logging/impl/stdio/Logging.cpp
new file mode 100644
index 0000000..95d2093
--- /dev/null
+++ b/src/platform/logging/impl/stdio/Logging.cpp
@@ -0,0 +1,20 @@
+/* See Project CHIP LICENSE file for licensing information. */
+
+#include <platform/logging/LogV.h>
+
+#include <stdio.h>
+
+namespace chip {
+namespace Logging {
+namespace Platform {
+
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
+{
+    printf("CHIP:%s: ", module);
+    vprintf(msg, v);
+    printf("\n");
+}
+
+} // namespace Platform
+} // namespace Logging
+} // namespace chip
diff --git a/src/platform/qpg6100/Logging.cpp b/src/platform/qpg6100/Logging.cpp
index ed04e6e..fd24448 100644
--- a/src/platform/qpg6100/Logging.cpp
+++ b/src/platform/qpg6100/Logging.cpp
@@ -1,38 +1,22 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP 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
- *
- *        http://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.
- */
-
-/**
- *    @file
- *          Provides implementations for the CHIP and LwIP logging functions
- *          on Qorvo platforms.
- */
+/* See Project CHIP LICENSE file for licensing information. */
+#include <platform/logging/LogV.h>
 
 #include "qvCHIP.h"
 
-#include <platform/internal/CHIPDeviceLayerInternal.h>
-#include <support/logging/CHIPLogging.h>
+#include <core/CHIPConfig.h>
+#include <platform/CHIPDeviceConfig.h>
+#include <support/logging/Constants.h>
+
+#include <ctype.h>
+#include <string.h>
 
 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
 #include <openthread/platform/logging.h>
 #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
 
-using namespace ::chip;
-using namespace ::chip::DeviceLayer;
-using namespace ::chip::DeviceLayer::Internal;
+constexpr uint8_t kPrintfModuleLwip       = 0x01;
+constexpr uint8_t kPrintfModuleOpenThread = 0x02;
+constexpr uint8_t kPrintfModuleLogging    = 0x03;
 
 namespace chip {
 namespace DeviceLayer {
@@ -50,55 +34,50 @@
 
 namespace chip {
 namespace Logging {
+namespace Platform {
 
 /**
  * CHIP log output function.
  */
 
-void LogV(uint8_t module, uint8_t category, const char * msg, va_list v)
+void LogV(const char * module, uint8_t category, const char * msg, va_list v)
 {
-    if (IsCategoryEnabled(category))
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    size_t prefixLen;
+
+    prefixLen = 0;
+
+    // No build-time switches in Qorvo logging module.
+    // Add small prefix to show logging category for now.
+    formattedMsg[prefixLen++] = '[';
+    switch (category)
     {
-        char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
-        size_t prefixLen;
-
-        constexpr size_t maxPrefixLen = chip::Logging::kMaxModuleNameLen + 3 + 3;
-        static_assert(sizeof(formattedMsg) > maxPrefixLen);
-
-        prefixLen = 0;
-
-        // No build-time switches in Qorvo logging module.
-        // Add small prefix to show logging category for now.
-        formattedMsg[prefixLen++] = '[';
-        switch (category)
-        {
-        case kLogCategory_Error:
-            formattedMsg[prefixLen++] = 'E';
-            break;
-        case kLogCategory_Detail:
-            formattedMsg[prefixLen++] = 'D';
-            break;
-        case kLogCategory_Progress:
-        default:
-            formattedMsg[prefixLen++] = 'P';
-            break;
-        }
-        formattedMsg[prefixLen++] = ']';
-        formattedMsg[prefixLen++] = '[';
-        GetModuleName(&formattedMsg[prefixLen], chip::Logging::kMaxModuleNameLen + 1, module);
-        prefixLen                 = strlen(formattedMsg);
-        formattedMsg[prefixLen++] = ']';
-        formattedMsg[prefixLen++] = ' ';
-
-        vsnprintf(&formattedMsg[prefixLen], sizeof(formattedMsg) - prefixLen, msg, v);
-
-        qvCHIP_Printf(module, formattedMsg);
-
-        // Let the application know that a log message has been emitted.
-        DeviceLayer::OnLogOutput();
+    case kLogCategory_Error:
+        formattedMsg[prefixLen++] = 'E';
+        break;
+    case kLogCategory_Detail:
+        formattedMsg[prefixLen++] = 'D';
+        break;
+    case kLogCategory_Progress:
+    default:
+        formattedMsg[prefixLen++] = 'P';
+        break;
     }
+    formattedMsg[prefixLen++] = ']';
+    formattedMsg[prefixLen++] = '[';
+    snprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - prefixLen, "][%s] ", module);
+    formattedMsg[sizeof(formattedMsg) - 2] = 0; // -2 to allow at least one char for the vsnprintf
+    prefixLen                              = strlen(formattedMsg);
+
+    vsnprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - prefixLen, msg, v);
+
+    qvCHIP_Printf(kPrintfModuleLogging, formattedMsg);
+
+    // Let the application know that a log message has been emitted.
+    chip::DeviceLayer::OnLogOutput();
 }
 
+} // namespace Platform
 } // namespace Logging
 } // namespace chip
 
@@ -107,7 +86,7 @@
  */
 extern "C" void LwIPLog(const char * msg, ...)
 {
-    char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
 
     va_list v;
 
@@ -121,24 +100,24 @@
         formattedMsg[len] = 0;
     }
 
-    qvCHIP_Printf(0x1, formattedMsg);
+    qvCHIP_Printf(kPrintfModuleLwip, formattedMsg);
 
     // Let the application know that a log message has been emitted.
-    DeviceLayer::OnLogOutput();
+    chip::DeviceLayer::OnLogOutput();
 }
 
 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
 extern "C" void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ...)
 {
-    char formattedMsg[CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE];
+    char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
 
     va_start(v, aFormat);
     size_t len = vsnprintf(formattedMsg, sizeof(formattedMsg), aFormat, v);
     va_end(v);
 
-    qvCHIP_Printf(0x2, formattedMsg);
+    qvCHIP_Printf(kPrintfModuleOpenThread, formattedMsg);
 
     // Let the application know that a log message has been emitted.
-    DeviceLayer::OnLogOutput();
+    chip::DeviceLayer::OnLogOutput();
 }
 #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD