diff options
Diffstat (limited to 'redfish-core/include/event_service_manager.hpp')
-rw-r--r-- | redfish-core/include/event_service_manager.hpp | 123 |
1 files changed, 60 insertions, 63 deletions
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index a1c4fb9fe1..00d77c8767 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -287,13 +287,13 @@ inline bool // NOLINTNEXTLINE bmcweb::split(result, sseFilter, ' '); - BMCWEB_LOG_DEBUG << "No of tokens in SEE query: " << result.size(); + BMCWEB_LOG_DEBUG("No of tokens in SEE query: {}", result.size()); constexpr uint8_t divisor = 4; constexpr uint8_t minTokenSize = 3; if (result.size() % divisor != minTokenSize) { - BMCWEB_LOG_ERROR << "Invalid SSE filter specified."; + BMCWEB_LOG_ERROR("Invalid SSE filter specified."); return false; } @@ -309,8 +309,8 @@ inline bool // SSE supports only "or" and "and" in query params. if ((separator != "or") && (separator != "and")) { - BMCWEB_LOG_ERROR - << "Invalid group operator in SSE query parameters"; + BMCWEB_LOG_ERROR( + "Invalid group operator in SSE query parameters"); return false; } } @@ -318,12 +318,12 @@ inline bool // SSE supports only "eq" as per spec. if (op != "eq") { - BMCWEB_LOG_ERROR - << "Invalid assignment operator in SSE query parameters"; + BMCWEB_LOG_ERROR( + "Invalid assignment operator in SSE query parameters"); return false; } - BMCWEB_LOG_DEBUG << key << " : " << value; + BMCWEB_LOG_DEBUG("{} : {}", key, value); if (key == "EventFormatType") { formatType = value; @@ -342,8 +342,7 @@ inline bool } else { - BMCWEB_LOG_ERROR << "Invalid property(" << key - << ")in SSE filter query."; + BMCWEB_LOG_ERROR("Invalid property({})in SSE filter query.", key); return false; } } @@ -477,14 +476,14 @@ class Subscription : public persistent_data::UserSubscription messageArgsView, timestamp, customText, bmcLogEntry) != 0) { - BMCWEB_LOG_DEBUG << "Read eventLog entry failed"; + BMCWEB_LOG_DEBUG("Read eventLog entry failed"); continue; } } if (logEntryArray.empty()) { - BMCWEB_LOG_DEBUG << "No log entries available to be transferred."; + BMCWEB_LOG_DEBUG("No log entries available to be transferred."); return; } @@ -521,9 +520,9 @@ class Subscription : public persistent_data::UserSubscription nlohmann::json msg; if (!telemetry::fillReport(msg, reportId, var)) { - BMCWEB_LOG_ERROR << "Failed to fill the MetricReport for DBus " - "Report with id " - << reportId; + BMCWEB_LOG_ERROR("Failed to fill the MetricReport for DBus " + "Report with id {}", + reportId); return; } @@ -553,7 +552,7 @@ class Subscription : public persistent_data::UserSubscription void setSubscriptionId(const std::string& id2) { - BMCWEB_LOG_DEBUG << "Subscription ID: " << id2; + BMCWEB_LOG_DEBUG("Subscription ID: {}", id2); subId = id2; } @@ -582,8 +581,8 @@ class Subscription : public persistent_data::UserSubscription // policy. 2XX is considered acceptable static boost::system::error_code retryRespHandler(unsigned int respCode) { - BMCWEB_LOG_DEBUG - << "Checking response code validity for SubscriptionEvent"; + BMCWEB_LOG_DEBUG( + "Checking response code validity for SubscriptionEvent"); if ((respCode < 200) || (respCode >= 300)) { return boost::system::errc::make_error_code( @@ -661,8 +660,8 @@ class EventServiceManager if (!status) { - BMCWEB_LOG_ERROR - << "Failed to validate and split destination url"; + BMCWEB_LOG_ERROR( + "Failed to validate and split destination url"); continue; } std::shared_ptr<Subscription> subValue = @@ -683,7 +682,7 @@ class EventServiceManager if (subValue->id.empty()) { - BMCWEB_LOG_ERROR << "Failed to add subscription"; + BMCWEB_LOG_ERROR("Failed to add subscription"); } subscriptionsMap.insert(std::pair(subValue->id, subValue)); @@ -704,13 +703,13 @@ class EventServiceManager std::ifstream eventConfigFile(eventServiceFile); if (!eventConfigFile.good()) { - BMCWEB_LOG_DEBUG << "Old eventService config not exist"; + BMCWEB_LOG_DEBUG("Old eventService config not exist"); return; } auto jsonData = nlohmann::json::parse(eventConfigFile, nullptr, false); if (jsonData.is_discarded()) { - BMCWEB_LOG_ERROR << "Old eventService config parse error."; + BMCWEB_LOG_ERROR("Old eventService config parse error."); return; } @@ -732,8 +731,8 @@ class EventServiceManager true); if (newSubscription == nullptr) { - BMCWEB_LOG_ERROR << "Problem reading subscription " - "from old persistent store"; + BMCWEB_LOG_ERROR("Problem reading subscription " + "from old persistent store"); continue; } @@ -765,9 +764,9 @@ class EventServiceManager if (retry <= 0) { - BMCWEB_LOG_ERROR - << "Failed to generate random number from old " - "persistent store"; + BMCWEB_LOG_ERROR( + "Failed to generate random number from old " + "persistent store"); continue; } } @@ -775,7 +774,7 @@ class EventServiceManager persistent_data::getConfig().writeData(); std::remove(eventServiceFile); - BMCWEB_LOG_DEBUG << "Remove old eventservice config"; + BMCWEB_LOG_DEBUG("Remove old eventservice config"); } } @@ -878,7 +877,7 @@ class EventServiceManager auto obj = subscriptionsMap.find(id); if (obj == subscriptionsMap.end()) { - BMCWEB_LOG_ERROR << "No subscription exist with ID:" << id; + BMCWEB_LOG_ERROR("No subscription exist with ID:{}", id); return nullptr; } std::shared_ptr<Subscription> subValue = obj->second; @@ -912,7 +911,7 @@ class EventServiceManager if (retry <= 0) { - BMCWEB_LOG_ERROR << "Failed to generate random number"; + BMCWEB_LOG_ERROR("Failed to generate random number"); return ""; } @@ -1024,7 +1023,7 @@ class EventServiceManager std::shared_ptr<Subscription> entry = it.second; if (entry->destinationUrl == destUrl) { - BMCWEB_LOG_ERROR << "Destination exist already" << destUrl; + BMCWEB_LOG_ERROR("Destination exist already{}", destUrl); return true; } } @@ -1049,7 +1048,7 @@ class EventServiceManager { if (!serviceEnabled || (noOfEventLogSubscribers == 0U)) { - BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions."; + BMCWEB_LOG_DEBUG("EventService disabled or no Subscriptions."); return; } nlohmann::json eventRecord = nlohmann::json::array(); @@ -1076,8 +1075,9 @@ class EventServiceManager { if (resType == resource) { - BMCWEB_LOG_INFO << "ResourceType " << resource - << " found in the subscribed list"; + BMCWEB_LOG_INFO( + "ResourceType {} found in the subscribed list", + resource); isSubscribed = true; break; } @@ -1103,7 +1103,7 @@ class EventServiceManager } else { - BMCWEB_LOG_INFO << "Not subscribed to this resource"; + BMCWEB_LOG_INFO("Not subscribed to this resource"); } } } @@ -1124,7 +1124,7 @@ class EventServiceManager std::ifstream logStream(redfishEventLogFile); if (!logStream.good()) { - BMCWEB_LOG_ERROR << " Redfish log file open failed \n"; + BMCWEB_LOG_ERROR(" Redfish log file open failed "); return; } std::string logEntry; @@ -1132,8 +1132,6 @@ class EventServiceManager { redfishLogFilePosition = logStream.tellg(); } - - BMCWEB_LOG_DEBUG << "Next Log Position : " << redfishLogFilePosition; } void readEventLogsFromFile() @@ -1141,7 +1139,7 @@ class EventServiceManager std::ifstream logStream(redfishEventLogFile); if (!logStream.good()) { - BMCWEB_LOG_ERROR << " Redfish log file open failed"; + BMCWEB_LOG_ERROR(" Redfish log file open failed"); return; } @@ -1177,7 +1175,7 @@ class EventServiceManager if (event_log::getEventLogParams(logEntry, timestamp, messageID, messageArgs) != 0) { - BMCWEB_LOG_DEBUG << "Read eventLog entry params failed"; + BMCWEB_LOG_DEBUG("Read eventLog entry params failed"); continue; } @@ -1196,14 +1194,14 @@ class EventServiceManager if (!serviceEnabled || noOfEventLogSubscribers == 0) { - BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions."; + BMCWEB_LOG_DEBUG("EventService disabled or no Subscriptions."); return; } if (eventRecords.empty()) { // No Records to send - BMCWEB_LOG_DEBUG << "No log entries available to be transferred."; + BMCWEB_LOG_DEBUG("No log entries available to be transferred."); return; } @@ -1231,7 +1229,7 @@ class EventServiceManager const std::size_t& bytesTransferred) { if (ec) { - BMCWEB_LOG_ERROR << "Callback Error: " << ec.message(); + BMCWEB_LOG_ERROR("Callback Error: {}", ec.message()); return; } std::size_t index = 0; @@ -1256,16 +1254,16 @@ class EventServiceManager continue; } - BMCWEB_LOG_DEBUG - << "Redfish log file created/deleted. event.name: " - << fileName; + BMCWEB_LOG_DEBUG( + "Redfish log file created/deleted. event.name: {}", + fileName); if (event.mask == IN_CREATE) { if (fileWatchDesc != -1) { - BMCWEB_LOG_DEBUG - << "Remove and Add inotify watcher on " - "redfish event log file"; + BMCWEB_LOG_DEBUG( + "Remove and Add inotify watcher on " + "redfish event log file"); // Remove existing inotify watcher and add // with new redfish event log file. inotify_rm_watch(inotifyFd, fileWatchDesc); @@ -1276,8 +1274,8 @@ class EventServiceManager inotifyFd, redfishEventLogFile, IN_MODIFY); if (fileWatchDesc == -1) { - BMCWEB_LOG_ERROR << "inotify_add_watch failed for " - "redfish log file."; + BMCWEB_LOG_ERROR("inotify_add_watch failed for " + "redfish log file."); return; } @@ -1317,7 +1315,7 @@ class EventServiceManager inotifyFd = inotify_init1(IN_NONBLOCK); if (inotifyFd == -1) { - BMCWEB_LOG_ERROR << "inotify_init1 failed."; + BMCWEB_LOG_ERROR("inotify_init1 failed."); return -1; } @@ -1327,8 +1325,8 @@ class EventServiceManager IN_CREATE | IN_MOVED_TO | IN_DELETE); if (dirWatchDesc == -1) { - BMCWEB_LOG_ERROR - << "inotify_add_watch failed for event log directory."; + BMCWEB_LOG_ERROR( + "inotify_add_watch failed for event log directory."); return -1; } @@ -1337,8 +1335,7 @@ class EventServiceManager IN_MODIFY); if (fileWatchDesc == -1) { - BMCWEB_LOG_ERROR - << "inotify_add_watch failed for redfish log file."; + BMCWEB_LOG_ERROR("inotify_add_watch failed for redfish log file."); // Don't return error if file not exist. // Watch on directory will handle create/delete of file. } @@ -1355,7 +1352,7 @@ class EventServiceManager { if (msg.is_method_error()) { - BMCWEB_LOG_ERROR << "TelemetryMonitor Signal error"; + BMCWEB_LOG_ERROR("TelemetryMonitor Signal error"); return; } @@ -1363,7 +1360,7 @@ class EventServiceManager std::string id = path.filename(); if (id.empty()) { - BMCWEB_LOG_ERROR << "Failed to get Id from path"; + BMCWEB_LOG_ERROR("Failed to get Id from path"); return; } @@ -1377,7 +1374,7 @@ class EventServiceManager [](const auto& x) { return x.first == "Readings"; }); if (found == props.end()) { - BMCWEB_LOG_INFO << "Failed to get Readings from Report properties"; + BMCWEB_LOG_INFO("Failed to get Readings from Report properties"); return; } @@ -1385,7 +1382,7 @@ class EventServiceManager std::get_if<telemetry::TimestampReadings>(&found->second); if (readings == nullptr) { - BMCWEB_LOG_INFO << "Failed to get Readings from Report properties"; + BMCWEB_LOG_INFO("Failed to get Readings from Report properties"); return; } @@ -1404,7 +1401,7 @@ class EventServiceManager { if (matchTelemetryMonitor) { - BMCWEB_LOG_DEBUG << "Metrics report signal - Unregister"; + BMCWEB_LOG_DEBUG("Metrics report signal - Unregister"); matchTelemetryMonitor.reset(); matchTelemetryMonitor = nullptr; } @@ -1414,11 +1411,11 @@ class EventServiceManager { if (!serviceEnabled || matchTelemetryMonitor) { - BMCWEB_LOG_DEBUG << "Not registering metric report signal."; + BMCWEB_LOG_DEBUG("Not registering metric report signal."); return; } - BMCWEB_LOG_DEBUG << "Metrics report signal - Register"; + BMCWEB_LOG_DEBUG("Metrics report signal - Register"); std::string matchStr = "type='signal',member='PropertiesChanged'," "interface='org.freedesktop.DBus.Properties'," "arg0=xyz.openbmc_project.Telemetry.Report"; |