Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make datamodel-provider inteface logging optional/configurable #36249

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ buildconfig_header("app_buildconfig") {
"CHIP_DEVICE_CONFIG_DYNAMIC_SERVER=${chip_build_controller_dynamic_server}",
"CHIP_CONFIG_ENABLE_BUSY_HANDLING_FOR_OPERATIONAL_SESSION_SETUP=${chip_enable_busy_handling_for_operational_session_setup}",
"CHIP_CONFIG_DATA_MODEL_CHECK_DIE_ON_FAILURE=${chip_data_model_check_die_on_failure}",
"CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING=${chip_data_model_extra_logging}",
]

if (chip_use_data_model_interface == "disabled") {
Expand Down
9 changes: 7 additions & 2 deletions src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ void WriteHandler::Close()
std::optional<bool> WriteHandler::IsListAttributePath(const ConcreteAttributePath & path)
{
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
VerifyOrReturnValue(mDataModelProvider != nullptr, std::nullopt,
ChipLogError(DataManagement, "Null data model while checking attribute properties."));
if (mDataModelProvider == nullptr)
{
#if CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING
ChipLogError(DataManagement, "Null data model while checking attribute properties.");
#endif
return std::nullopt;
}

auto info = mDataModelProvider->GetAttributeInfo(path);
if (!info.has_value())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ std::optional<CommandId> EnumeratorCommandFinder::FindCommandId(Operation operat

if (err != CHIP_NO_ERROR)
{
#if CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING
// Report the error here since we lose actual error. This generally should NOT be possible as CommandHandlerInterface
// usually returns unimplemented or should just work for our use case (our callback never fails)
ChipLogError(DataManagement, "Enumerate error: %" CHIP_ERROR_FORMAT, err.Format());
#endif
return kInvalidCommandId;
}

Expand All @@ -155,8 +157,10 @@ std::variant<CHIP_ERROR, DataModel::ClusterInfo> LoadClusterInfo(const ConcreteC
DataVersion * versionPtr = emberAfDataVersionStorage(path);
if (versionPtr == nullptr)
{
#if CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING
ChipLogError(AppServer, "Failed to get data version for %d/" ChipLogFormatMEI, static_cast<int>(path.mEndpointId),
ChipLogValueMEI(cluster.clusterId));
#endif
return CHIP_ERROR_NOT_FOUND;
}

Expand Down Expand Up @@ -211,7 +215,7 @@ DataModel::ClusterEntry FirstServerClusterEntry(EndpointId endpointId, const Emb
return *entryValue;
}

#if CHIP_ERROR_LOGGING
#if CHIP_ERROR_LOGGING && CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING
if (CHIP_ERROR * errValue = std::get_if<CHIP_ERROR>(&entry))
{
ChipLogError(AppServer, "Failed to load cluster entry: %" CHIP_ERROR_FORMAT, errValue->Format());
Expand Down Expand Up @@ -571,7 +575,7 @@ std::optional<DataModel::ClusterInfo> CodegenDataModelProvider::GetClusterInfo(c

if (CHIP_ERROR * err = std::get_if<CHIP_ERROR>(&info))
{
#if CHIP_ERROR_LOGGING
#if CHIP_ERROR_LOGGING && CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING
ChipLogError(AppServer, "Failed to load cluster info: %" CHIP_ERROR_FORMAT, err->Format());
#else
(void) err->Format();
Expand Down
6 changes: 6 additions & 0 deletions src/app/common_flags.gni
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ declare_args() {
# If/once the chip_use_data_model_interface flag is removed or does not support
# a `check` option, this should alwo be removed
chip_data_model_check_die_on_failure = false

# This controls if more logging is supposed to be enabled into the data models.
# This is an optimization for small-flash size devices as extra logging requires
# additional flash for messages & code for formatting.
chip_data_model_extra_logging =
current_os == "linux" || current_os == "darwin" || current_os == "android"
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 2 additions & 0 deletions src/app/reporting/Read-DataModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ DataModel::ActionReturnStatus RetrieveClusterData(DataModel::Provider * dataMode
if (!status.IsOutOfSpaceEncodingResponse())
{
DataModel::ActionReturnStatus::StringStorage storage;
#if CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING
ChipLogError(DataManagement, "Failed to read attribute: %s", status.c_str(storage));
#endif
}
return status;
}
Expand Down
Loading