diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 44c30043d..b796f4c9e 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -179,6 +179,24 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) deviceInfoprovider->SetStorageDelegate(mDeviceStorage); } +#if CHIP_CONFIG_ENABLE_SERVER_IM_EVENT + // Initialize event logging subsystem + err = sGlobalEventIdCounter.Init(mDeviceStorage, &DefaultStorageKeyAllocator::IMEventNumber, + CHIP_DEVICE_CONFIG_EVENT_ID_COUNTER_EPOCH); + SuccessOrExit(err); + + { + ::chip::app::LogStorageResources logStorageResources[] = { + { &sDebugEventBuffer[0], sizeof(sDebugEventBuffer), ::chip::app::PriorityLevel::Debug }, + { &sInfoEventBuffer[0], sizeof(sInfoEventBuffer), ::chip::app::PriorityLevel::Info }, + { &sCritEventBuffer[0], sizeof(sCritEventBuffer), ::chip::app::PriorityLevel::Critical } + }; + + chip::app::EventManagement::GetInstance().Init(&mExchangeMgr, CHIP_NUM_EVENT_LOGGING_BUFFERS, &sLoggingBuffer[0], + &logStorageResources[0], &sGlobalEventIdCounter); + } +#endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT + // This initializes clusters, so should come after lower level initialization. InitDataModelHandler(&mExchangeMgr); @@ -229,24 +247,6 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) chip::Dnssd::Resolver::Instance().Init(DeviceLayer::UDPEndPointManager()); -#if CHIP_CONFIG_ENABLE_SERVER_IM_EVENT - // Initialize event logging subsystem - err = sGlobalEventIdCounter.Init(mDeviceStorage, &DefaultStorageKeyAllocator::IMEventNumber, - CHIP_DEVICE_CONFIG_EVENT_ID_COUNTER_EPOCH); - SuccessOrExit(err); - - { - ::chip::app::LogStorageResources logStorageResources[] = { - { &sDebugEventBuffer[0], sizeof(sDebugEventBuffer), ::chip::app::PriorityLevel::Debug }, - { &sInfoEventBuffer[0], sizeof(sInfoEventBuffer), ::chip::app::PriorityLevel::Info }, - { &sCritEventBuffer[0], sizeof(sCritEventBuffer), ::chip::app::PriorityLevel::Critical } - }; - - chip::app::EventManagement::GetInstance().Init(&mExchangeMgr, CHIP_NUM_EVENT_LOGGING_BUFFERS, &sLoggingBuffer[0], - &logStorageResources[0], &sGlobalEventIdCounter); - } -#endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT - #if defined(CHIP_APP_USE_ECHO) err = InitEchoHandler(&mExchangeMgr); SuccessOrExit(err);