Skip to content

Commit

Permalink
Replace usages of emberPrintln with ChipLogProgress calls (#27035)
Browse files Browse the repository at this point in the history
* Replace debug print calls via:

```
rg emberAfPrintln src examples --files-with-matches | xargs sd 'emberAfPrintln\(EMBER_AF_PRINT_DEBUG, ("[^)]*\);)' 'ChipLogDetail($1'
```

* Replace one more missing bit

* Remove all references of debug-printing or ember-print

* Add Zcl as a log source for various files

* remove one more unused file

* Replace detail log with zcl

* Replace emberAfDoorLockClusterPrintln

* Replace all the other printlns

* Ran clang-format

* Remove usage of emberAfAttributesFlush as it was defined as empty before

* Port emberAfPrintBuffer into attribute-table

* Fix typo in replacement of logs

* Restyled by whitespace

* Restyled by clang-format

* Update the print calls to log as well, not just println

* clang-format

* Restyled by clang-format

* zap regen

* emberAfprintAttributeTable was never used. Removing

* Removed one more unused method

---------

Co-authored-by: Andrei Litvin <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Aug 21, 2023
1 parent f2cf3e5 commit 2439761
Show file tree
Hide file tree
Showing 24 changed files with 560 additions and 3,240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointI
return Status::Success;
}
}
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Cannot find the mode %u", mode);
ChipLogProgress(Zcl, "Cannot find the mode %u", mode);
return Status::InvalidCommand;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
// TODO: Watch for LockState, DoorState, Mode, etc changes and trigger appropriate action
if (attributePath.mClusterId == Clusters::DoorLock::Id)
{
emberAfDoorLockClusterPrintln("Door Lock attribute changed");
ChipLogProgress(Zcl, "Door Lock attribute changed");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointI
return Status::Success;
}
}
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Cannot find the mode %u", mode);
ChipLogProgress(Zcl, "Cannot find the mode %u", mode);
return Status::InvalidCommand;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/

#include "static-supported-modes-manager.h"
#include <app/util/debug-printing.h>
#include <app/util/ember-print.h>
#include <platform/ESP32/ESP32Config.h>

using namespace chip;
Expand Down Expand Up @@ -176,7 +174,7 @@ Status StaticSupportedModesManager::getModeOptionByMode(unsigned short endpointI
return Status::Success;
}
}
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Cannot find the mode %u", mode);
ChipLogProgress(Zcl, "Cannot find the mode %u", mode);
return Status::InvalidCommand;
}

Expand Down
6 changes: 3 additions & 3 deletions examples/window-app/common/src/WindowApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void WindowApp::DispatchEventAttributeChange(chip::EndpointId endpoint, chip::At

if (nullptr == cover)
{
emberAfWindowCoveringClusterPrint("Ep[%u] not supported AttributeId=%u\n", endpoint, (unsigned int) attribute);
ChipLogProgress(Zcl, "Ep[%u] not supported AttributeId=%u\n", endpoint, (unsigned int) attribute);
return;
}

Expand Down Expand Up @@ -675,7 +675,7 @@ void WindowApp::Cover::OnTiltTimeout(WindowApp::Timer & timer)
void WindowApp::Cover::SchedulePositionSet(chip::Percent100ths position, bool isTilt)
{
CoverWorkData * data = chip::Platform::New<CoverWorkData>();
VerifyOrReturn(data != nullptr, emberAfWindowCoveringClusterPrint("Cover::SchedulePositionSet - Out of Memory for WorkData"));
VerifyOrReturn(data != nullptr, ChipLogProgress(Zcl, "Cover::SchedulePositionSet - Out of Memory for WorkData"));

data->mEndpointId = mEndpoint;
data->percent100ths = position;
Expand All @@ -701,7 +701,7 @@ void WindowApp::Cover::CallbackPositionSet(intptr_t arg)
void WindowApp::Cover::ScheduleOperationalStateSet(OperationalState opState, bool isTilt)
{
CoverWorkData * data = chip::Platform::New<CoverWorkData>();
VerifyOrReturn(data != nullptr, emberAfWindowCoveringClusterPrint("Cover::OperationalStatusSet - Out of Memory for WorkData"));
VerifyOrReturn(data != nullptr, ChipLogProgress(Zcl, "Cover::OperationalStatusSet - Out of Memory for WorkData"));

data->mEndpointId = mEndpoint;
data->opState = opState;
Expand Down
1 change: 0 additions & 1 deletion src/app/chip_data_model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ function(chip_configure_data_model APP_TARGET)
# ${CHIP_APP_BASE_DIR}/util/ClientMonitoringRegistrationTable.cpp
${CHIP_APP_BASE_DIR}/util/DataModelHandler.cpp
${CHIP_APP_BASE_DIR}/util/ember-compatibility-functions.cpp
${CHIP_APP_BASE_DIR}/util/ember-print.cpp
${CHIP_APP_BASE_DIR}/util/error-mapping.cpp
${CHIP_APP_BASE_DIR}/util/generic-callback-stubs.cpp
${CHIP_APP_BASE_DIR}/util/message.cpp
Expand Down
1 change: 0 additions & 1 deletion src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ template("chip_data_model") {
"${_app_root}/util/binding-table.cpp",
"${_app_root}/util/binding-table.h",
"${_app_root}/util/ember-compatibility-functions.cpp",
"${_app_root}/util/ember-print.cpp",
"${_app_root}/util/error-mapping.cpp",
"${_app_root}/util/generic-callback-stubs.cpp",
"${_app_root}/util/message.cpp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ bool emberAfAdministratorCommissioningClusterRevokeCommissioningCallback(

void MatterAdministratorCommissioningPluginServerInitCallback()
{
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "Initiating Admin Commissioning cluster.");
ChipLogProgress(Zcl, "Initiating Admin Commissioning cluster.");
registerAttributeAccessOverride(&gAdminCommissioningAttrAccess);
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static void sendDefaultResponse(app::CommandHandler * commandObj, const app::Con
{
if (commandObj->AddStatus(commandPath, status) != CHIP_NO_ERROR)
{
emberAfBarrierControlClusterPrintln("Failed to send default response");
ChipLogProgress(Zcl, "Failed to send default response");
}
}

Expand All @@ -301,7 +301,7 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(
EndpointId endpoint = commandPath.mEndpointId;
Status status = Status::Success;

emberAfBarrierControlClusterPrintln("RX: GoToPercentCallback p=%d", percentOpen);
ChipLogProgress(Zcl, "RX: GoToPercentCallback p=%d", percentOpen);

if (isRemoteLockoutOn(endpoint))
{
Expand All @@ -319,8 +319,8 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(
state.currentPosition = getCurrentPosition(endpoint);
state.targetPosition = percentOpen;
state.delayMs = calculateDelayMs(endpoint, state.targetPosition, &state.increasing);
emberAfBarrierControlClusterPrintln("Scheduling barrier move from %d to %d with %" PRIu32 "ms delay", state.currentPosition,
state.targetPosition, state.delayMs);
ChipLogProgress(Zcl, "Scheduling barrier move from %d to %d with %" PRIu32 "ms delay", state.currentPosition,
state.targetPosition, state.delayMs);
scheduleTimerCallbackMs(endpoint, state.delayMs);

if (state.currentPosition < state.targetPosition)
Expand Down Expand Up @@ -353,6 +353,6 @@ void MatterBarrierControlPluginServerInitCallback() {}

void MatterBarrierControlClusterServerShutdownCallback(EndpointId endpoint)
{
emberAfBarrierControlClusterPrintln("Shuting barrier control server cluster on endpoint %d", endpoint);
ChipLogProgress(Zcl, "Shuting barrier control server cluster on endpoint %d", endpoint);
cancelEndpointTimerCallback(endpoint);
}
13 changes: 6 additions & 7 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,23 +1649,23 @@ void ColorControlServer::updateHueSatCommand(EndpointId endpoint)
Attributes::EnhancedCurrentHue::Set(endpoint, colorHueTransitionState->currentEnhancedHue);
Attributes::CurrentHue::Set(endpoint, static_cast<uint8_t>(colorHueTransitionState->currentEnhancedHue >> 8));

emberAfColorControlClusterPrintln("Enhanced Hue %d endpoint %d", colorHueTransitionState->currentEnhancedHue, endpoint);
ChipLogProgress(Zcl, "Enhanced Hue %d endpoint %d", colorHueTransitionState->currentEnhancedHue, endpoint);
}
}
else
{
if (previousHue != colorHueTransitionState->currentHue)
{
Attributes::CurrentHue::Set(colorHueTransitionState->endpoint, colorHueTransitionState->currentHue);
emberAfColorControlClusterPrintln("Hue %d endpoint %d", colorHueTransitionState->currentHue, endpoint);
ChipLogProgress(Zcl, "Hue %d endpoint %d", colorHueTransitionState->currentHue, endpoint);
}
}

if (previousSaturation != colorSaturationTransitionState->currentValue)
{
Attributes::CurrentSaturation::Set(colorSaturationTransitionState->endpoint,
(uint8_t) colorSaturationTransitionState->currentValue);
emberAfColorControlClusterPrintln("Saturation %d endpoint %d", colorSaturationTransitionState->currentValue, endpoint);
ChipLogProgress(Zcl, "Saturation %d endpoint %d", colorSaturationTransitionState->currentValue, endpoint);
}

computePwmFromHsv(endpoint);
Expand Down Expand Up @@ -2014,8 +2014,7 @@ void ColorControlServer::updateXYCommand(EndpointId endpoint)
Attributes::CurrentX::Set(endpoint, colorXTransitionState->currentValue);
Attributes::CurrentY::Set(endpoint, colorYTransitionState->currentValue);

emberAfColorControlClusterPrintln("Color X %d Color Y %d", colorXTransitionState->currentValue,
colorYTransitionState->currentValue);
ChipLogProgress(Zcl, "Color X %d Color Y %d", colorXTransitionState->currentValue, colorYTransitionState->currentValue);

computePwmFromXy(endpoint);
}
Expand Down Expand Up @@ -2215,7 +2214,7 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint)

Attributes::ColorTemperatureMireds::Set(endpoint, colorTempTransitionState->currentValue);

emberAfColorControlClusterPrintln("Color Temperature %d", colorTempTransitionState->currentValue);
ChipLogProgress(Zcl, "Color Temperature %d", colorTempTransitionState->currentValue);

computePwmFromTemp(endpoint);
}
Expand Down Expand Up @@ -2705,7 +2704,7 @@ void emberAfColorControlClusterServerInitCallback(EndpointId endpoint)

void MatterColorControlClusterServerShutdownCallback(EndpointId endpoint)
{
emberAfColorControlClusterPrintln("Shuting down color control server cluster on endpoint %d", endpoint);
ChipLogProgress(Zcl, "Shuting down color control server cluster on endpoint %d", endpoint);
ColorControlServer::Instance().cancelEndpointTimerCallback(endpoint);
}

Expand Down
Loading

0 comments on commit 2439761

Please sign in to comment.