Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "log_manager.hpp" |
| 4 | |
| 5 | #include "elog_entry.hpp" |
| 6 | #include "elog_meta.hpp" |
| 7 | #include "elog_serialize.hpp" |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 8 | #include "extensions.hpp" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 9 | |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 10 | #include <poll.h> |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 11 | #include <sys/inotify.h> |
Adriana Kobylak | 1db1bd3 | 2016-10-10 11:39:20 -0500 | [diff] [blame] | 12 | #include <systemd/sd-bus.h> |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 13 | #include <systemd/sd-journal.h> |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 14 | #include <unistd.h> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 15 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 16 | #include <cassert> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 17 | #include <chrono> |
| 18 | #include <cstdio> |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 19 | #include <cstring> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 20 | #include <fstream> |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 21 | #include <functional> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 22 | #include <future> |
| 23 | #include <iostream> |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 24 | #include <map> |
Saqib Khan | 2bb1519 | 2017-02-13 13:19:55 -0600 | [diff] [blame] | 25 | #include <phosphor-logging/log.hpp> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 26 | #include <sdbusplus/vtable.hpp> |
| 27 | #include <set> |
| 28 | #include <string> |
| 29 | #include <vector> |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 30 | |
| 31 | using namespace phosphor::logging; |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 32 | using namespace std::chrono; |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 33 | using sdbusplus::exception::SdBusError; |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 34 | extern const std::map<metadata::Metadata, |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 35 | std::function<metadata::associations::Type>> |
| 36 | meta; |
Adriana Kobylak | 1db1bd3 | 2016-10-10 11:39:20 -0500 | [diff] [blame] | 37 | |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 38 | namespace phosphor |
| 39 | { |
| 40 | namespace logging |
| 41 | { |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 42 | namespace internal |
| 43 | { |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 44 | inline auto getLevel(const std::string& errMsg) |
| 45 | { |
| 46 | auto reqLevel = Entry::Level::Error; // Default to Error |
| 47 | |
| 48 | auto levelmap = g_errLevelMap.find(errMsg); |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 49 | if (levelmap != g_errLevelMap.end()) |
Marri Devender Rao | 7656fba | 2017-08-06 05:42:52 -0500 | [diff] [blame] | 50 | { |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 51 | reqLevel = static_cast<Entry::Level>(levelmap->second); |
Marri Devender Rao | 7656fba | 2017-08-06 05:42:52 -0500 | [diff] [blame] | 52 | } |
| 53 | |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 54 | return reqLevel; |
| 55 | } |
| 56 | |
Nagaraju Goruganti | 477b731 | 2018-06-25 23:28:58 -0500 | [diff] [blame] | 57 | int Manager::getRealErrSize() |
| 58 | { |
| 59 | return realErrors.size(); |
| 60 | } |
| 61 | |
| 62 | int Manager::getInfoErrSize() |
| 63 | { |
| 64 | return infoErrors.size(); |
| 65 | } |
| 66 | |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 67 | void Manager::commit(uint64_t transactionId, std::string errMsg) |
| 68 | { |
| 69 | auto level = getLevel(errMsg); |
| 70 | _commit(transactionId, std::move(errMsg), level); |
| 71 | } |
| 72 | |
| 73 | void Manager::commitWithLvl(uint64_t transactionId, std::string errMsg, |
| 74 | uint32_t errLvl) |
| 75 | { |
| 76 | _commit(transactionId, std::move(errMsg), |
| 77 | static_cast<Entry::Level>(errLvl)); |
| 78 | } |
| 79 | |
| 80 | void Manager::_commit(uint64_t transactionId, std::string&& errMsg, |
| 81 | Entry::Level errLvl) |
| 82 | { |
Adriana Kobylak | 7298dc2 | 2017-01-24 12:21:50 -0600 | [diff] [blame] | 83 | constexpr const auto transactionIdVar = "TRANSACTION_ID"; |
Adriana Kobylak | 27c87d9 | 2017-03-06 12:45:09 -0600 | [diff] [blame] | 84 | // Length of 'TRANSACTION_ID' string. |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 85 | constexpr const auto transactionIdVarSize = std::strlen(transactionIdVar); |
Adriana Kobylak | 27c87d9 | 2017-03-06 12:45:09 -0600 | [diff] [blame] | 86 | // Length of 'TRANSACTION_ID=' string. |
| 87 | constexpr const auto transactionIdVarOffset = transactionIdVarSize + 1; |
Adriana Kobylak | 1db1bd3 | 2016-10-10 11:39:20 -0500 | [diff] [blame] | 88 | |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 89 | // Flush all the pending log messages into the journal |
| 90 | journalSync(); |
Adriana Kobylak | cfd9a7d | 2017-06-07 11:57:31 -0500 | [diff] [blame] | 91 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 92 | sd_journal* j = nullptr; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 93 | int rc = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 94 | if (rc < 0) |
| 95 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 96 | logging::log<logging::level::ERR>( |
| 97 | "Failed to open journal", |
| 98 | logging::entry("DESCRIPTION=%s", strerror(-rc))); |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 99 | return; |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 100 | } |
| 101 | |
Adriana Kobylak | 7298dc2 | 2017-01-24 12:21:50 -0600 | [diff] [blame] | 102 | std::string transactionIdStr = std::to_string(transactionId); |
Adriana Kobylak | d722b3a | 2017-02-28 12:10:44 -0600 | [diff] [blame] | 103 | std::set<std::string> metalist; |
| 104 | auto metamap = g_errMetaMap.find(errMsg); |
| 105 | if (metamap != g_errMetaMap.end()) |
| 106 | { |
| 107 | metalist.insert(metamap->second.begin(), metamap->second.end()); |
| 108 | } |
Adriana Kobylak | 7298dc2 | 2017-01-24 12:21:50 -0600 | [diff] [blame] | 109 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 110 | // Add _PID field information in AdditionalData. |
Jayanth Othayoth | db18ebe | 2017-09-04 00:48:02 -0500 | [diff] [blame] | 111 | metalist.insert("_PID"); |
| 112 | |
Tom Joseph | 7a33ee4 | 2017-07-25 00:04:20 +0530 | [diff] [blame] | 113 | std::vector<std::string> additionalData; |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 114 | |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 115 | // Read the journal from the end to get the most recent entry first. |
| 116 | // The result from the sd_journal_get_data() is of the form VARIABLE=value. |
| 117 | SD_JOURNAL_FOREACH_BACKWARDS(j) |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 118 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 119 | const char* data = nullptr; |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 120 | size_t length = 0; |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 121 | |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 122 | // Look for the transaction id metadata variable |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 123 | rc = sd_journal_get_data(j, transactionIdVar, (const void**)&data, |
| 124 | &length); |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 125 | if (rc < 0) |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 126 | { |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 127 | // This journal entry does not have the TRANSACTION_ID |
| 128 | // metadata variable. |
| 129 | continue; |
| 130 | } |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 131 | |
Adriana Kobylak | 27c87d9 | 2017-03-06 12:45:09 -0600 | [diff] [blame] | 132 | // journald does not guarantee that sd_journal_get_data() returns NULL |
| 133 | // terminated strings, so need to specify the size to use to compare, |
| 134 | // use the returned length instead of anything that relies on NULL |
| 135 | // terminators like strlen(). |
| 136 | // The data variable is in the form of 'TRANSACTION_ID=1234'. Remove |
| 137 | // the TRANSACTION_ID characters plus the (=) sign to do the comparison. |
| 138 | // 'data + transactionIdVarOffset' will be in the form of '1234'. |
| 139 | // 'length - transactionIdVarOffset' will be the length of '1234'. |
| 140 | if ((length <= (transactionIdVarOffset)) || |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 141 | (transactionIdStr.compare(0, transactionIdStr.size(), |
Adriana Kobylak | 27c87d9 | 2017-03-06 12:45:09 -0600 | [diff] [blame] | 142 | data + transactionIdVarOffset, |
| 143 | length - transactionIdVarOffset) != 0)) |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 144 | { |
| 145 | // The value of the TRANSACTION_ID metadata is not the requested |
| 146 | // transaction id number. |
| 147 | continue; |
| 148 | } |
| 149 | |
| 150 | // Search for all metadata variables in the current journal entry. |
| 151 | for (auto i = metalist.cbegin(); i != metalist.cend();) |
| 152 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 153 | rc = sd_journal_get_data(j, (*i).c_str(), (const void**)&data, |
| 154 | &length); |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 155 | if (rc < 0) |
| 156 | { |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 157 | // Metadata variable not found, check next metadata variable. |
| 158 | i++; |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 159 | continue; |
| 160 | } |
| 161 | |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 162 | // Metadata variable found, save it and remove it from the set. |
| 163 | additionalData.emplace_back(data, length); |
| 164 | i = metalist.erase(i); |
| 165 | } |
| 166 | if (metalist.empty()) |
| 167 | { |
| 168 | // All metadata variables found, break out of journal loop. |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 169 | break; |
| 170 | } |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 171 | } |
| 172 | if (!metalist.empty()) |
| 173 | { |
| 174 | // Not all the metadata variables were found in the journal. |
| 175 | for (auto& metaVarStr : metalist) |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 176 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 177 | logging::log<logging::level::INFO>( |
| 178 | "Failed to find metadata", |
| 179 | logging::entry("META_FIELD=%s", metaVarStr.c_str())); |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 183 | sd_journal_close(j); |
| 184 | |
Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 185 | createEntry(errMsg, errLvl, additionalData); |
| 186 | } |
| 187 | |
| 188 | void Manager::createEntry(std::string errMsg, Entry::Level errLvl, |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 189 | std::vector<std::string> additionalData, |
| 190 | const FFDCEntries& ffdc) |
Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 191 | { |
| 192 | if (!Extensions::disableDefaultLogCaps()) |
| 193 | { |
| 194 | if (errLvl < Entry::sevLowerLimit) |
| 195 | { |
| 196 | if (realErrors.size() >= ERROR_CAP) |
| 197 | { |
| 198 | erase(realErrors.front()); |
| 199 | } |
| 200 | } |
| 201 | else |
| 202 | { |
| 203 | if (infoErrors.size() >= ERROR_INFO_CAP) |
| 204 | { |
| 205 | erase(infoErrors.front()); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 210 | entryId++; |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 211 | if (errLvl >= Entry::sevLowerLimit) |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 212 | { |
| 213 | infoErrors.push_back(entryId); |
| 214 | } |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 215 | else |
| 216 | { |
| 217 | realErrors.push_back(entryId); |
| 218 | } |
Adriana Kobylak | c5f0bbd | 2017-01-22 14:56:04 -0600 | [diff] [blame] | 219 | auto ms = std::chrono::duration_cast<std::chrono::milliseconds>( |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 220 | std::chrono::system_clock::now().time_since_epoch()) |
| 221 | .count(); |
| 222 | auto objPath = std::string(OBJ_ENTRY) + '/' + std::to_string(entryId); |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 223 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 224 | AssociationList objects{}; |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 225 | processMetadata(errMsg, additionalData, objects); |
| 226 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 227 | auto e = std::make_unique<Entry>(busLog, objPath, entryId, |
| 228 | ms, // Milliseconds since 1970 |
| 229 | errLvl, std::move(errMsg), |
| 230 | std::move(additionalData), |
| 231 | std::move(objects), fwVersion, *this); |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 232 | serialize(*e); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 233 | |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 234 | if (isQuiesceOnErrorEnabled()) |
| 235 | { |
| 236 | checkQuiesceOnError(*e); |
| 237 | } |
| 238 | |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 239 | doExtensionLogCreate(*e, ffdc); |
| 240 | |
| 241 | // Note: No need to close the file descriptors in the FFDC. |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 242 | |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 243 | entries.insert(std::make_pair(entryId, std::move(e))); |
Adriana Kobylak | 1db1bd3 | 2016-10-10 11:39:20 -0500 | [diff] [blame] | 244 | } |
| 245 | |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 246 | bool Manager::isQuiesceOnErrorEnabled() |
| 247 | { |
| 248 | std::variant<bool> property; |
| 249 | |
| 250 | auto method = this->busLog.new_method_call( |
| 251 | "xyz.openbmc_project.Settings", "/xyz/openbmc_project/logging/settings", |
| 252 | "org.freedesktop.DBus.Properties", "Get"); |
| 253 | |
| 254 | method.append("xyz.openbmc_project.Logging.Settings", "QuiesceOnHwError"); |
| 255 | |
| 256 | try |
| 257 | { |
| 258 | auto reply = this->busLog.call(method); |
| 259 | reply.read(property); |
| 260 | } |
| 261 | catch (const SdBusError& e) |
| 262 | { |
| 263 | log<level::ERR>("Error reading QuiesceOnHwError property", |
| 264 | entry("ERROR=%s", e.what())); |
| 265 | throw; |
| 266 | } |
| 267 | |
| 268 | return std::get<bool>(property); |
| 269 | } |
| 270 | |
Andrew Geissler | e4960ee | 2020-03-30 14:31:52 -0500 | [diff] [blame] | 271 | bool Manager::isCalloutPresent(const Entry& entry) |
| 272 | { |
| 273 | for (const auto& c : entry.additionalData()) |
| 274 | { |
| 275 | if (c.find("CALLOUT_") != std::string::npos) |
| 276 | { |
| 277 | return true; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | return false; |
| 282 | } |
| 283 | |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame^] | 284 | void Manager::findAndRemoveResolvedBlocks() |
| 285 | { |
| 286 | for (auto& entry : entries) |
| 287 | { |
| 288 | if (entry.second->resolved()) |
| 289 | { |
| 290 | checkAndRemoveBlockingError(entry.first); |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | void Manager::onEntryResolve(sdbusplus::message::message& msg) |
| 296 | { |
| 297 | using Interface = std::string; |
| 298 | using Property = std::string; |
| 299 | using Value = std::string; |
| 300 | using Properties = std::map<Property, sdbusplus::message::variant<Value>>; |
| 301 | |
| 302 | Interface interface; |
| 303 | Properties properties; |
| 304 | |
| 305 | msg.read(interface, properties); |
| 306 | |
| 307 | for (const auto& p : properties) |
| 308 | { |
| 309 | if (p.first == "Resolved") |
| 310 | { |
| 311 | findAndRemoveResolvedBlocks(); |
| 312 | return; |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 317 | void Manager::checkQuiesceOnError(const Entry& entry) |
| 318 | { |
Andrew Geissler | e4960ee | 2020-03-30 14:31:52 -0500 | [diff] [blame] | 319 | |
| 320 | if (!isCalloutPresent(entry)) |
| 321 | { |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | logging::log<logging::level::INFO>( |
| 326 | "QuiesceOnError set and callout present"); |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 327 | |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame^] | 328 | auto blockPath = |
| 329 | std::string(OBJ_LOGGING) + "/block" + std::to_string(entry.id()); |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 330 | auto blockObj = |
| 331 | std::make_unique<Block>(this->busLog, blockPath, entry.id()); |
| 332 | this->blockingErrors.push_back(std::move(blockObj)); |
| 333 | |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame^] | 334 | // Register call back if log is resolved |
| 335 | using namespace sdbusplus::bus::match::rules; |
| 336 | auto entryPath = std::string(OBJ_ENTRY) + '/' + std::to_string(entry.id()); |
| 337 | auto callback = std::make_unique<sdbusplus::bus::match::match>( |
| 338 | this->busLog, |
| 339 | propertiesChanged(entryPath, "xyz.openbmc_project.Logging.Entry"), |
| 340 | std::bind(std::mem_fn(&Manager::onEntryResolve), this, |
| 341 | std::placeholders::_1)); |
| 342 | |
| 343 | propChangedEntryCallback.insert( |
| 344 | std::make_pair(entry.id(), std::move(callback))); |
| 345 | |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 346 | // TODO in later commit in this series |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 347 | // Call systemd to quiesce host |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 348 | } |
| 349 | |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 350 | void Manager::doExtensionLogCreate(const Entry& entry, const FFDCEntries& ffdc) |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 351 | { |
| 352 | // Make the association <endpointpath>/<endpointtype> paths |
| 353 | std::vector<std::string> assocs; |
| 354 | for (const auto& [forwardType, reverseType, endpoint] : |
| 355 | entry.associations()) |
| 356 | { |
| 357 | std::string e{endpoint}; |
| 358 | e += '/' + reverseType; |
| 359 | assocs.push_back(e); |
| 360 | } |
| 361 | |
| 362 | for (auto& create : Extensions::getCreateFunctions()) |
| 363 | { |
| 364 | try |
| 365 | { |
| 366 | create(entry.message(), entry.id(), entry.timestamp(), |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 367 | entry.severity(), entry.additionalData(), assocs, ffdc); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 368 | } |
| 369 | catch (std::exception& e) |
| 370 | { |
| 371 | log<level::ERR>("An extension's create function threw an exception", |
| 372 | phosphor::logging::entry("ERROR=%s", e.what())); |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 377 | void Manager::processMetadata(const std::string& errorName, |
| 378 | const std::vector<std::string>& additionalData, |
| 379 | AssociationList& objects) const |
| 380 | { |
| 381 | // additionalData is a list of "metadata=value" |
| 382 | constexpr auto separator = '='; |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 383 | for (const auto& entryItem : additionalData) |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 384 | { |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 385 | auto found = entryItem.find(separator); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 386 | if (std::string::npos != found) |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 387 | { |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 388 | auto metadata = entryItem.substr(0, found); |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 389 | auto iter = meta.find(metadata); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 390 | if (meta.end() != iter) |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 391 | { |
| 392 | (iter->second)(metadata, additionalData, objects); |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 398 | void Manager::checkAndRemoveBlockingError(uint32_t entryId) |
| 399 | { |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame^] | 400 | // First look for blocking object and remove |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 401 | auto it = find_if( |
| 402 | blockingErrors.begin(), blockingErrors.end(), |
| 403 | [&](std::unique_ptr<Block>& obj) { return obj->entryId == entryId; }); |
| 404 | if (it != blockingErrors.end()) |
| 405 | { |
| 406 | blockingErrors.erase(it); |
| 407 | } |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame^] | 408 | |
| 409 | // Now remove the callback looking for the error to be resolved |
| 410 | auto resolveFind = propChangedEntryCallback.find(entryId); |
| 411 | if (resolveFind != propChangedEntryCallback.end()) |
| 412 | { |
| 413 | propChangedEntryCallback.erase(resolveFind); |
| 414 | } |
| 415 | |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 416 | return; |
| 417 | } |
| 418 | |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 419 | void Manager::erase(uint32_t entryId) |
| 420 | { |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 421 | auto entryFound = entries.find(entryId); |
| 422 | if (entries.end() != entryFound) |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 423 | { |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 424 | for (auto& func : Extensions::getDeleteProhibitedFunctions()) |
| 425 | { |
| 426 | try |
| 427 | { |
| 428 | bool prohibited = false; |
| 429 | func(entryId, prohibited); |
| 430 | if (prohibited) |
| 431 | { |
| 432 | // Future work remains to throw an error here. |
| 433 | return; |
| 434 | } |
| 435 | } |
| 436 | catch (std::exception& e) |
| 437 | { |
| 438 | log<level::ERR>( |
| 439 | "An extension's deleteProhibited function threw " |
| 440 | "an exception", |
| 441 | entry("ERROR=%s", e.what())); |
| 442 | } |
| 443 | } |
| 444 | |
Deepak Kodihalli | 3388799 | 2017-06-13 07:06:49 -0500 | [diff] [blame] | 445 | // Delete the persistent representation of this error. |
| 446 | fs::path errorPath(ERRLOG_PERSIST_PATH); |
Marri Devender Rao | 8959efc | 2017-11-17 00:13:41 -0600 | [diff] [blame] | 447 | errorPath /= std::to_string(entryId); |
Deepak Kodihalli | 3388799 | 2017-06-13 07:06:49 -0500 | [diff] [blame] | 448 | fs::remove(errorPath); |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 449 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 450 | auto removeId = [](std::list<uint32_t>& ids, uint32_t id) { |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 451 | auto it = std::find(ids.begin(), ids.end(), id); |
| 452 | if (it != ids.end()) |
| 453 | { |
| 454 | ids.erase(it); |
| 455 | } |
| 456 | }; |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 457 | if (entryFound->second->severity() >= Entry::sevLowerLimit) |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 458 | { |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 459 | removeId(infoErrors, entryId); |
| 460 | } |
| 461 | else |
| 462 | { |
| 463 | removeId(realErrors, entryId); |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 464 | } |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 465 | entries.erase(entryFound); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 466 | |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 467 | checkAndRemoveBlockingError(entryId); |
| 468 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 469 | for (auto& remove : Extensions::getDeleteFunctions()) |
| 470 | { |
| 471 | try |
| 472 | { |
| 473 | remove(entryId); |
| 474 | } |
| 475 | catch (std::exception& e) |
| 476 | { |
| 477 | log<level::ERR>("An extension's delete function threw an " |
| 478 | "exception", |
| 479 | entry("ERROR=%s", e.what())); |
| 480 | } |
| 481 | } |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 482 | } |
Marri Devender Rao | 8959efc | 2017-11-17 00:13:41 -0600 | [diff] [blame] | 483 | else |
| 484 | { |
| 485 | logging::log<level::ERR>("Invalid entry ID to delete", |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 486 | logging::entry("ID=%d", entryId)); |
Marri Devender Rao | 8959efc | 2017-11-17 00:13:41 -0600 | [diff] [blame] | 487 | } |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 488 | } |
| 489 | |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 490 | void Manager::restore() |
| 491 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 492 | auto sanity = [](const auto& id, const auto& restoredId) { |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 493 | return id == restoredId; |
| 494 | }; |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 495 | std::vector<uint32_t> errorIds; |
| 496 | |
| 497 | fs::path dir(ERRLOG_PERSIST_PATH); |
| 498 | if (!fs::exists(dir) || fs::is_empty(dir)) |
| 499 | { |
| 500 | return; |
| 501 | } |
| 502 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 503 | for (auto& file : fs::directory_iterator(dir)) |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 504 | { |
| 505 | auto id = file.path().filename().c_str(); |
| 506 | auto idNum = std::stol(id); |
| 507 | auto e = std::make_unique<Entry>( |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 508 | busLog, std::string(OBJ_ENTRY) + '/' + id, idNum, *this); |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 509 | if (deserialize(file.path(), *e)) |
| 510 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 511 | // validate the restored error entry id |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 512 | if (sanity(static_cast<uint32_t>(idNum), e->id())) |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 513 | { |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 514 | e->emit_object_added(); |
| 515 | if (e->severity() >= Entry::sevLowerLimit) |
| 516 | { |
| 517 | infoErrors.push_back(idNum); |
| 518 | } |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 519 | else |
| 520 | { |
| 521 | realErrors.push_back(idNum); |
| 522 | } |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 523 | |
| 524 | entries.insert(std::make_pair(idNum, std::move(e))); |
| 525 | errorIds.push_back(idNum); |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 526 | } |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 527 | else |
| 528 | { |
| 529 | logging::log<logging::level::ERR>( |
| 530 | "Failed in sanity check while restoring error entry. " |
| 531 | "Ignoring error entry", |
| 532 | logging::entry("ID_NUM=%d", idNum), |
| 533 | logging::entry("ENTRY_ID=%d", e->id())); |
| 534 | } |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | |
Vishwanatha Subbanna | 37af9ba | 2017-09-28 16:33:53 +0530 | [diff] [blame] | 538 | if (!errorIds.empty()) |
| 539 | { |
| 540 | entryId = *(std::max_element(errorIds.begin(), errorIds.end())); |
| 541 | } |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 542 | } |
| 543 | |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 544 | void Manager::journalSync() |
| 545 | { |
| 546 | bool syncRequested = false; |
| 547 | auto fd = -1; |
| 548 | auto rc = -1; |
| 549 | auto wd = -1; |
| 550 | auto bus = sdbusplus::bus::new_default(); |
| 551 | |
| 552 | auto start = |
| 553 | duration_cast<microseconds>(steady_clock::now().time_since_epoch()) |
| 554 | .count(); |
| 555 | |
Matthew Barth | 5991389 | 2019-08-27 15:43:48 -0500 | [diff] [blame] | 556 | // Each time an error log is committed, a request to sync the journal |
| 557 | // must occur and block that error log commit until it completes. A 5sec |
| 558 | // block is done to allow sufficient time for the journal to be synced. |
| 559 | // |
| 560 | // Number of loop iterations = 3 for the following reasons: |
| 561 | // Iteration #1: Requests a journal sync by killing the journald service. |
| 562 | // Iteration #2: Setup an inotify watch to monitor the synced file that |
| 563 | // journald updates with the timestamp the last time the |
| 564 | // journal was flushed. |
| 565 | // Iteration #3: Poll to wait until inotify reports an event which blocks |
| 566 | // the error log from being commited until the sync completes. |
| 567 | constexpr auto maxRetry = 3; |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 568 | for (int i = 0; i < maxRetry; i++) |
| 569 | { |
| 570 | // Read timestamp from synced file |
| 571 | constexpr auto syncedPath = "/run/systemd/journal/synced"; |
| 572 | std::ifstream syncedFile(syncedPath); |
| 573 | if (syncedFile.fail()) |
| 574 | { |
Adriana Kobylak | 7d111a8 | 2018-09-04 10:14:24 -0500 | [diff] [blame] | 575 | // If the synced file doesn't exist, a sync request will create it. |
| 576 | if (errno != ENOENT) |
| 577 | { |
| 578 | log<level::ERR>("Failed to open journal synced file", |
| 579 | entry("FILENAME=%s", syncedPath), |
| 580 | entry("ERRNO=%d", errno)); |
| 581 | return; |
| 582 | } |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 583 | } |
Adriana Kobylak | 7d111a8 | 2018-09-04 10:14:24 -0500 | [diff] [blame] | 584 | else |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 585 | { |
Adriana Kobylak | 7d111a8 | 2018-09-04 10:14:24 -0500 | [diff] [blame] | 586 | // Only read the synced file if it exists. |
| 587 | // See if a sync happened by now |
| 588 | std::string timestampStr; |
| 589 | std::getline(syncedFile, timestampStr); |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 590 | auto timestamp = std::stoll(timestampStr); |
Adriana Kobylak | 7d111a8 | 2018-09-04 10:14:24 -0500 | [diff] [blame] | 591 | if (timestamp >= start) |
| 592 | { |
Troy Lee | b7f392a | 2019-11-19 14:34:56 +0800 | [diff] [blame] | 593 | break; |
Adriana Kobylak | 7d111a8 | 2018-09-04 10:14:24 -0500 | [diff] [blame] | 594 | } |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | // Let's ask for a sync, but only once |
| 598 | if (!syncRequested) |
| 599 | { |
| 600 | syncRequested = true; |
| 601 | |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 602 | constexpr auto JOURNAL_UNIT = "systemd-journald.service"; |
| 603 | auto signal = SIGRTMIN + 1; |
| 604 | |
| 605 | auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, |
| 606 | SYSTEMD_INTERFACE, "KillUnit"); |
| 607 | method.append(JOURNAL_UNIT, "main", signal); |
| 608 | bus.call(method); |
| 609 | if (method.is_method_error()) |
| 610 | { |
| 611 | log<level::ERR>("Failed to kill journal service"); |
Troy Lee | b7f392a | 2019-11-19 14:34:56 +0800 | [diff] [blame] | 612 | break; |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 613 | } |
| 614 | continue; |
| 615 | } |
| 616 | |
| 617 | // Let's install the inotify watch, if we didn't do that yet. This watch |
| 618 | // monitors the syncedFile for when journald updates it with a newer |
| 619 | // timestamp. This means the journal has been flushed. |
| 620 | if (fd < 0) |
| 621 | { |
| 622 | fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); |
| 623 | if (fd < 0) |
| 624 | { |
| 625 | log<level::ERR>("Failed to create inotify watch", |
| 626 | entry("ERRNO=%d", errno)); |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | constexpr auto JOURNAL_RUN_PATH = "/run/systemd/journal"; |
| 631 | wd = inotify_add_watch(fd, JOURNAL_RUN_PATH, |
| 632 | IN_MOVED_TO | IN_DONT_FOLLOW | IN_ONLYDIR); |
| 633 | if (wd < 0) |
| 634 | { |
| 635 | log<level::ERR>("Failed to watch journal directory", |
| 636 | entry("PATH=%s", JOURNAL_RUN_PATH), |
| 637 | entry("ERRNO=%d", errno)); |
| 638 | close(fd); |
| 639 | return; |
| 640 | } |
| 641 | continue; |
| 642 | } |
| 643 | |
| 644 | // Let's wait until inotify reports an event |
| 645 | struct pollfd fds = { |
| 646 | .fd = fd, |
| 647 | .events = POLLIN, |
| 648 | }; |
| 649 | constexpr auto pollTimeout = 5; // 5 seconds |
| 650 | rc = poll(&fds, 1, pollTimeout * 1000); |
| 651 | if (rc < 0) |
| 652 | { |
| 653 | log<level::ERR>("Failed to add event", entry("ERRNO=%d", errno), |
| 654 | entry("ERR=%s", strerror(-rc))); |
| 655 | inotify_rm_watch(fd, wd); |
| 656 | close(fd); |
| 657 | return; |
| 658 | } |
| 659 | else if (rc == 0) |
| 660 | { |
| 661 | log<level::INFO>("Poll timeout, no new journal synced data", |
| 662 | entry("TIMEOUT=%d", pollTimeout)); |
| 663 | break; |
| 664 | } |
| 665 | |
| 666 | // Read from the specified file descriptor until there is no new data, |
| 667 | // throwing away everything read since the timestamp will be read at the |
| 668 | // beginning of the loop. |
| 669 | constexpr auto maxBytes = 64; |
| 670 | uint8_t buffer[maxBytes]; |
| 671 | while (read(fd, buffer, maxBytes) > 0) |
| 672 | ; |
| 673 | } |
| 674 | |
Adriana Kobylak | 4a029f2 | 2018-05-23 12:58:19 -0500 | [diff] [blame] | 675 | if (fd != -1) |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 676 | { |
Adriana Kobylak | 4a029f2 | 2018-05-23 12:58:19 -0500 | [diff] [blame] | 677 | if (wd != -1) |
| 678 | { |
| 679 | inotify_rm_watch(fd, wd); |
| 680 | } |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 681 | close(fd); |
| 682 | } |
| 683 | |
| 684 | return; |
| 685 | } |
| 686 | |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 687 | std::string Manager::readFWVersion() |
| 688 | { |
| 689 | std::string version; |
| 690 | std::ifstream versionFile{BMC_VERSION_FILE}; |
| 691 | std::string line; |
| 692 | static constexpr auto VERSION_ID = "VERSION_ID="; |
| 693 | |
| 694 | while (std::getline(versionFile, line)) |
| 695 | { |
| 696 | if (line.find(VERSION_ID) != std::string::npos) |
| 697 | { |
| 698 | auto pos = line.find_first_of('"') + 1; |
| 699 | version = line.substr(pos, line.find_last_of('"') - pos); |
| 700 | break; |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | if (version.empty()) |
| 705 | { |
| 706 | log<level::ERR>("Unable to read BMC firmware version"); |
| 707 | } |
| 708 | |
| 709 | return version; |
| 710 | } |
| 711 | |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 712 | void Manager::create(const std::string& message, Entry::Level severity, |
| 713 | const std::map<std::string, std::string>& additionalData) |
| 714 | { |
| 715 | // Convert the map into a vector of "key=value" strings |
| 716 | std::vector<std::string> ad; |
| 717 | metadata::associations::combine(additionalData, ad); |
| 718 | |
| 719 | createEntry(message, severity, ad); |
| 720 | } |
| 721 | |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 722 | void Manager::createWithFFDC( |
| 723 | const std::string& message, Entry::Level severity, |
| 724 | const std::map<std::string, std::string>& additionalData, |
| 725 | const FFDCEntries& ffdc) |
| 726 | { |
| 727 | // Convert the map into a vector of "key=value" strings |
| 728 | std::vector<std::string> ad; |
| 729 | metadata::associations::combine(additionalData, ad); |
| 730 | |
| 731 | createEntry(message, severity, ad, ffdc); |
| 732 | } |
| 733 | |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 734 | } // namespace internal |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 735 | } // namespace logging |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 736 | } // namespace phosphor |