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

Improve LogEvent API #12711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 9 additions & 7 deletions src/app/EventLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,25 @@ class EventLogger : public EventLoggingDelegate
* `ClusterID` and `EventId`.
*
* @param[in] apDelegate The EventLoggingDelegate to serialize the event data
*
* @param[in] aEventOptions The options for the event metadata.
*
* @param[in] aEndpoint The current cluster's Endpoint Id
* @param[in] aUrgent The EventOption Type, kUrgent or kNotUrgent
* @param[out] aEventNumber The event Number if the event was written to the
* log, 0 otherwise. The Event number is expected to monotonically increase.
*
* @return CHIP_ERROR CHIP Error Code
*/
template <typename T>
CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventOptions aEventOptions, EventNumber & aEventNumber)
CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventNumber & aEventNumber,
EventOptions::Type aUrgent = EventOptions::Type::kNotUrgent)
{
EventLogger<T> eventData(aEventData);
ConcreteEventPath path(aEndpoint, aEventData.GetClusterId(), aEventData.GetEventId());
EventManagement & logMgmt = chip::app::EventManagement::GetInstance();
aEventOptions.mPath = path;
aEventOptions.mPriority = aEventData.GetPriorityLevel();
return logMgmt.LogEvent(&eventData, aEventOptions, aEventNumber);
EventOptions eventOptions;
yunhanw-google marked this conversation as resolved.
Show resolved Hide resolved
eventOptions.mUrgent = aUrgent;
eventOptions.mPath = path;
eventOptions.mPriority = aEventData.GetPriorityLevel();
return logMgmt.LogEvent(&eventData, eventOptions, aEventNumber);
}

} // namespace app
Expand Down
3 changes: 1 addition & 2 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,11 @@ bool emberAfTestClusterClusterTestEmitTestEventRequestCallback(
Structs::SimpleStruct::Type arg4;
DataModel::List<const Structs::SimpleStruct::Type> arg5;
DataModel::List<const SimpleEnum> arg6;
EventOptions eventOptions;

// TODO: Add code to pull arg4, arg5 and arg6 from the arguments of the command
Events::TestEvent::Type event{ commandData.arg1, commandData.arg2, commandData.arg3, arg4, arg5, arg6 };

if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, eventOptions, responseData.value))
if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, responseData.value))
{
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE);
return true;
Expand Down