Skip to content

Commit

Permalink
Move chip::Logging::LogV to platform-specific implementation (#4741)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andy31415 authored and pull[bot] committed Mar 4, 2021
1 parent 6c0f597 commit 522edeb
Show file tree
Hide file tree
Showing 31 changed files with 715 additions and 1,044 deletions.
13 changes: 13 additions & 0 deletions build/chip/chip_test_suite.gni
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ template("chip_test_suite") {
forward_variables_from(invoker, "*", [ "tests" ])

output_dir = "${root_out_dir}/lib"

if (!defined(invoker.public_deps)) {
public_deps = []
}

# TODO: figure out a way to auto-define dependency on stdio logging.
# This dep is required since libSupportLayer now does not include
# a default implementation.
#
# Tests such as TestInetEndPoint need to exercise the system event
# loop however they do not seem to include a logging binding so this
# is forcefully added here.
public_deps += [ "${chip_root}/src/platform/logging:stdio" ]
}

if (chip_link_tests) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/util/ember-print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void emberAfPrintBuffer(int category, const uint8_t * buffer, uint16_t length, b
{
if (buffer != nullptr && length > 0)
{
constexpr uint16_t kBufferSize = CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE;
constexpr uint16_t kBufferSize = CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE;
const char * perByteFormatStr = withSpace ? "%02hhX " : "%02hhX";
const uint8_t perByteCharCount = withSpace ? 3 : 2;
const uint16_t bytesPerBuffer = static_cast<uint16_t>((kBufferSize - 1) / perByteCharCount);
Expand Down
10 changes: 0 additions & 10 deletions src/crypto/tests/CHIPCryptoPALTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,16 +1355,6 @@ static void TestSPAKE2P_RFC(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, numOfTestsRan == numOfTestVectors);
}

namespace chip {
namespace Logging {
void __attribute__((weak)) LogV(uint8_t module, uint8_t category, const char * format, va_list argptr)
{
(void) module, (void) category;
vfprintf(stderr, format, argptr);
}
} // namespace Logging
} // namespace chip

/**
* Test Suite. It lists all the test functions.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/darwin/Framework/CHIP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPDevicePlatformConfig.h>",
CONFIG_NETWORK_LAYER_INET,
CONFIG_NETWORK_LAYER_BLE,
"CHIP_LOGGING_STYLE_EXTERNAL=1",
"CHIP_DEVICE_LAYER_TARGET=Darwin",
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
"CHIP_DEVICE_LAYER_TARGET_LINUX=0",
Expand Down Expand Up @@ -646,7 +645,6 @@
"CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=<platform/Darwin/CHIPDevicePlatformConfig.h>",
CONFIG_NETWORK_LAYER_INET,
CONFIG_NETWORK_LAYER_BLE,
"CHIP_LOGGING_STYLE_EXTERNAL=1",
"CHIP_DEVICE_LAYER_TARGET=Darwin",
"CHIP_DEVICE_LAYER_TARGET_DARWIN=1",
"CHIP_DEVICE_LAYER_TARGET_LINUX=0",
Expand Down
3 changes: 0 additions & 3 deletions src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ for define in "${defines[@]}"; do
CHIP_CRYPTO_*)
continue
;;
CHIP_LOGGING_STYLE_*)
continue
;;
esac
target_defines+=,\"${define//\"/\\\"}\"
done
Expand Down
9 changes: 0 additions & 9 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@
#define CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE 100
#endif

/**
* CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE
*
* The maximum size (in bytes) of a debug logging message.
*/
#ifndef CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE
#define CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE 256
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_FACTORY_PROVISIONING
*
Expand Down
13 changes: 0 additions & 13 deletions src/lib/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ buildconfig_header("chip_buildconfig") {

chip_target_style_unix = chip_target_style == "unix"
chip_target_style_embedded = chip_target_style == "embedded"
chip_logging_style_android = chip_logging_style == "android"
chip_logging_style_darwin = chip_logging_style == "darwin"
chip_logging_style_external = chip_logging_style == "external"
chip_logging_style_stdio = chip_logging_style == "stdio"
chip_logging_style_stdio_weak = chip_logging_style == "stdio_weak"
chip_logging_style_stdio_with_timestamps =
chip_logging_style == "stdio_with_timestamps"

chip_config_memory_management_malloc =
chip_config_memory_management == "malloc"
Expand All @@ -54,12 +47,6 @@ buildconfig_header("chip_buildconfig") {
"CHIP_CONFIG_ENABLE_ARG_PARSER=${chip_config_enable_arg_parser}",
"CHIP_TARGET_STYLE_UNIX=${chip_target_style_unix}",
"CHIP_TARGET_STYLE_EMBEDDED=${chip_target_style_embedded}",
"CHIP_LOGGING_STYLE_ANDROID=${chip_logging_style_android}",
"CHIP_LOGGING_STYLE_DARWIN=${chip_logging_style_darwin}",
"CHIP_LOGGING_STYLE_EXTERNAL=${chip_logging_style_external}",
"CHIP_LOGGING_STYLE_STDIO=${chip_logging_style_stdio}",
"CHIP_LOGGING_STYLE_STDIO_WEAK=${chip_logging_style_stdio_weak}",
"CHIP_LOGGING_STYLE_STDIO_WITH_TIMESTAMPS=${chip_logging_style_stdio_with_timestamps}",
"CHIP_CONFIG_MEMORY_MGMT_MALLOC=${chip_config_memory_management_malloc}",
"HAVE_MALLOC=${chip_config_memory_management_malloc}",
"HAVE_FREE=${chip_config_memory_management_malloc}",
Expand Down
Loading

0 comments on commit 522edeb

Please sign in to comment.