From fa9f9772a32804c1e8ed945c6e47fbb1b4d3cc86 Mon Sep 17 00:00:00 2001 From: Peter Qiu <114182543+zqiu-nest@users.noreply.github.com> Date: Tue, 4 Oct 2022 16:08:10 -0400 Subject: [PATCH] [Linux]Add build arg to allow external logging implementation (#22829) * Linux: add build arg to allow external logging implementation The will allow target platform/application to provide its own logging implementation, such as writing logs to file, instead of logging to stdout. * Update core.gni --- src/lib/core/core.gni | 5 +++++ src/platform/Linux/BUILD.gn | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/core/core.gni b/src/lib/core/core.gni index c49357dffcab68..da4cf547e7c80a 100644 --- a/src/lib/core/core.gni +++ b/src/lib/core/core.gni @@ -47,6 +47,11 @@ declare_args() { # Configure chip logging to output through pigweed logging. chip_use_pw_logging = false + # Configure chip logging to output through external logging implementation. + # External code will need to provide implementation for CHIP log output + # function (LogV), which is defined in "src/platform/logging/LogV.h". + chip_use_external_logging = false + # Enable short error strings. chip_config_short_error_str = false diff --git a/src/platform/Linux/BUILD.gn b/src/platform/Linux/BUILD.gn index 5a66ab0ccc335d..2088bfb83daf00 100644 --- a/src/platform/Linux/BUILD.gn +++ b/src/platform/Linux/BUILD.gn @@ -67,7 +67,6 @@ static_library("Linux") { "InetPlatformConfig.h", "KeyValueStoreManagerImpl.cpp", "KeyValueStoreManagerImpl.h", - "Logging.cpp", "NetworkCommissioningDriver.h", "NetworkCommissioningEthernetDriver.cpp", "PlatformManagerImpl.cpp", @@ -78,6 +77,10 @@ static_library("Linux") { "SystemTimeSupport.cpp", ] + if (!chip_use_external_logging) { + sources += [ "Logging.cpp" ] + } + if (chip_enable_openthread) { sources += [ "NetworkCommissioningThreadDriver.cpp" ] }