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" |
Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 9 | #include "util.hpp" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 10 | |
Adriana Kobylak | 1db1bd3 | 2016-10-10 11:39:20 -0500 | [diff] [blame] | 11 | #include <systemd/sd-bus.h> |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 12 | #include <systemd/sd-journal.h> |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 13 | #include <unistd.h> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 14 | |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 15 | #include <phosphor-logging/lg2.hpp> |
| 16 | #include <sdbusplus/vtable.hpp> |
| 17 | #include <xyz/openbmc_project/State/Host/server.hpp> |
| 18 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 19 | #include <cassert> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 20 | #include <chrono> |
| 21 | #include <cstdio> |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 22 | #include <cstring> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 23 | #include <fstream> |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 24 | #include <functional> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 25 | #include <future> |
| 26 | #include <iostream> |
Patrick Venture | 30047bf | 2018-11-01 18:52:15 -0700 | [diff] [blame] | 27 | #include <map> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 28 | #include <set> |
| 29 | #include <string> |
Patrick Williams | b01a5b4 | 2021-08-28 15:11:45 -0500 | [diff] [blame] | 30 | #include <string_view> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 31 | #include <vector> |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 32 | |
Adriana Kobylak | 5f4247f | 2018-03-15 10:27:05 -0500 | [diff] [blame] | 33 | using namespace std::chrono; |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 34 | extern const std::map< |
| 35 | phosphor::logging::metadata::Metadata, |
| 36 | std::function<phosphor::logging::metadata::associations::Type>> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 37 | meta; |
Adriana Kobylak | 1db1bd3 | 2016-10-10 11:39:20 -0500 | [diff] [blame] | 38 | |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 39 | namespace phosphor |
| 40 | { |
| 41 | namespace logging |
| 42 | { |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 43 | namespace internal |
| 44 | { |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 45 | inline auto getLevel(const std::string& errMsg) |
| 46 | { |
| 47 | auto reqLevel = Entry::Level::Error; // Default to Error |
| 48 | |
| 49 | auto levelmap = g_errLevelMap.find(errMsg); |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 50 | if (levelmap != g_errLevelMap.end()) |
Marri Devender Rao | 7656fba | 2017-08-06 05:42:52 -0500 | [diff] [blame] | 51 | { |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 52 | reqLevel = static_cast<Entry::Level>(levelmap->second); |
Marri Devender Rao | 7656fba | 2017-08-06 05:42:52 -0500 | [diff] [blame] | 53 | } |
| 54 | |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 55 | return reqLevel; |
| 56 | } |
| 57 | |
Nagaraju Goruganti | 477b731 | 2018-06-25 23:28:58 -0500 | [diff] [blame] | 58 | int Manager::getRealErrSize() |
| 59 | { |
| 60 | return realErrors.size(); |
| 61 | } |
| 62 | |
| 63 | int Manager::getInfoErrSize() |
| 64 | { |
| 65 | return infoErrors.size(); |
| 66 | } |
| 67 | |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 68 | uint32_t Manager::commit(uint64_t transactionId, std::string errMsg) |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 69 | { |
| 70 | auto level = getLevel(errMsg); |
| 71 | _commit(transactionId, std::move(errMsg), level); |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 72 | return entryId; |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 73 | } |
| 74 | |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 75 | uint32_t Manager::commitWithLvl(uint64_t transactionId, std::string errMsg, |
| 76 | uint32_t errLvl) |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 77 | { |
| 78 | _commit(transactionId, std::move(errMsg), |
| 79 | static_cast<Entry::Level>(errLvl)); |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 80 | return entryId; |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 81 | } |
| 82 | |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 83 | void Manager::_commit(uint64_t transactionId [[maybe_unused]], |
| 84 | std::string&& errMsg, Entry::Level errLvl) |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 85 | { |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 86 | std::vector<std::string> additionalData{}; |
| 87 | |
| 88 | // When running as a test-case, the system may have a LOT of journal |
| 89 | // data and we may not have permissions to do some of the journal sync |
| 90 | // operations. Just skip over them. |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 91 | if (!IS_UNIT_TEST) |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 92 | { |
Patrick Williams | b01a5b4 | 2021-08-28 15:11:45 -0500 | [diff] [blame] | 93 | static constexpr auto transactionIdVar = |
| 94 | std::string_view{"TRANSACTION_ID"}; |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 95 | // Length of 'TRANSACTION_ID' string. |
Patrick Williams | b01a5b4 | 2021-08-28 15:11:45 -0500 | [diff] [blame] | 96 | static constexpr auto transactionIdVarSize = transactionIdVar.size(); |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 97 | // Length of 'TRANSACTION_ID=' string. |
Patrick Williams | b01a5b4 | 2021-08-28 15:11:45 -0500 | [diff] [blame] | 98 | static constexpr auto transactionIdVarOffset = transactionIdVarSize + 1; |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 99 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 100 | // Flush all the pending log messages into the journal |
Matt Spinler | 271d143 | 2023-01-18 13:58:05 -0600 | [diff] [blame] | 101 | util::journalSync(); |
Adriana Kobylak | 7298dc2 | 2017-01-24 12:21:50 -0600 | [diff] [blame] | 102 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 103 | sd_journal* j = nullptr; |
| 104 | int rc = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 105 | if (rc < 0) |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 106 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 107 | lg2::error("Failed to open journal: {ERROR}", "ERROR", |
| 108 | strerror(-rc)); |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 109 | return; |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 110 | } |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 111 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 112 | std::string transactionIdStr = std::to_string(transactionId); |
| 113 | std::set<std::string> metalist; |
| 114 | auto metamap = g_errMetaMap.find(errMsg); |
| 115 | if (metamap != g_errMetaMap.end()) |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 116 | { |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 117 | metalist.insert(metamap->second.begin(), metamap->second.end()); |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 118 | } |
| 119 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 120 | // Add _PID field information in AdditionalData. |
| 121 | metalist.insert("_PID"); |
| 122 | |
| 123 | // Read the journal from the end to get the most recent entry first. |
| 124 | // The result from the sd_journal_get_data() is of the form |
| 125 | // VARIABLE=value. |
| 126 | SD_JOURNAL_FOREACH_BACKWARDS(j) |
Adriana Kobylak | fbe8872 | 2017-02-22 16:49:59 -0600 | [diff] [blame] | 127 | { |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 128 | const char* data = nullptr; |
| 129 | size_t length = 0; |
| 130 | |
| 131 | // Look for the transaction id metadata variable |
Patrick Williams | b01a5b4 | 2021-08-28 15:11:45 -0500 | [diff] [blame] | 132 | rc = sd_journal_get_data(j, transactionIdVar.data(), |
| 133 | (const void**)&data, &length); |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 134 | if (rc < 0) |
| 135 | { |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 136 | // This journal entry does not have the TRANSACTION_ID |
| 137 | // metadata variable. |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 138 | continue; |
| 139 | } |
| 140 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 141 | // journald does not guarantee that sd_journal_get_data() returns |
| 142 | // NULL terminated strings, so need to specify the size to use to |
| 143 | // compare, use the returned length instead of anything that relies |
| 144 | // on NULL terminators like strlen(). The data variable is in the |
| 145 | // form of 'TRANSACTION_ID=1234'. Remove the TRANSACTION_ID |
| 146 | // characters plus the (=) sign to do the comparison. 'data + |
| 147 | // transactionIdVarOffset' will be in the form of '1234'. 'length - |
| 148 | // transactionIdVarOffset' will be the length of '1234'. |
| 149 | if ((length <= (transactionIdVarOffset)) || |
| 150 | (transactionIdStr.compare( |
| 151 | 0, transactionIdStr.size(), data + transactionIdVarOffset, |
| 152 | length - transactionIdVarOffset) != 0)) |
| 153 | { |
| 154 | // The value of the TRANSACTION_ID metadata is not the requested |
| 155 | // transaction id number. |
| 156 | continue; |
| 157 | } |
Adriana Kobylak | 9aa7d78 | 2017-02-18 09:20:49 -0600 | [diff] [blame] | 158 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 159 | // Search for all metadata variables in the current journal entry. |
| 160 | for (auto i = metalist.cbegin(); i != metalist.cend();) |
| 161 | { |
| 162 | rc = sd_journal_get_data(j, (*i).c_str(), (const void**)&data, |
| 163 | &length); |
| 164 | if (rc < 0) |
| 165 | { |
| 166 | // Metadata variable not found, check next metadata |
| 167 | // variable. |
| 168 | i++; |
| 169 | continue; |
| 170 | } |
Adriana Kobylak | d311bc8 | 2016-10-16 09:54:40 -0500 | [diff] [blame] | 171 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 172 | // Metadata variable found, save it and remove it from the set. |
| 173 | additionalData.emplace_back(data, length); |
| 174 | i = metalist.erase(i); |
| 175 | } |
| 176 | if (metalist.empty()) |
| 177 | { |
| 178 | // All metadata variables found, break out of journal loop. |
| 179 | break; |
| 180 | } |
| 181 | } |
| 182 | if (!metalist.empty()) |
| 183 | { |
| 184 | // Not all the metadata variables were found in the journal. |
| 185 | for (auto& metaVarStr : metalist) |
| 186 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 187 | lg2::info("Failed to find metadata: {META_FIELD}", "META_FIELD", |
| 188 | metaVarStr); |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
| 192 | sd_journal_close(j); |
| 193 | } |
Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 194 | createEntry(errMsg, errLvl, additionalData); |
| 195 | } |
| 196 | |
| 197 | void Manager::createEntry(std::string errMsg, Entry::Level errLvl, |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 198 | std::vector<std::string> additionalData, |
| 199 | const FFDCEntries& ffdc) |
Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 200 | { |
| 201 | if (!Extensions::disableDefaultLogCaps()) |
| 202 | { |
| 203 | if (errLvl < Entry::sevLowerLimit) |
| 204 | { |
| 205 | if (realErrors.size() >= ERROR_CAP) |
| 206 | { |
| 207 | erase(realErrors.front()); |
| 208 | } |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | if (infoErrors.size() >= ERROR_INFO_CAP) |
| 213 | { |
| 214 | erase(infoErrors.front()); |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 219 | entryId++; |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 220 | if (errLvl >= Entry::sevLowerLimit) |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 221 | { |
| 222 | infoErrors.push_back(entryId); |
| 223 | } |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 224 | else |
| 225 | { |
| 226 | realErrors.push_back(entryId); |
| 227 | } |
Adriana Kobylak | c5f0bbd | 2017-01-22 14:56:04 -0600 | [diff] [blame] | 228 | auto ms = std::chrono::duration_cast<std::chrono::milliseconds>( |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 229 | std::chrono::system_clock::now().time_since_epoch()) |
| 230 | .count(); |
| 231 | auto objPath = std::string(OBJ_ENTRY) + '/' + std::to_string(entryId); |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 232 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 233 | AssociationList objects{}; |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 234 | processMetadata(errMsg, additionalData, objects); |
| 235 | |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 236 | auto e = std::make_unique<Entry>( |
| 237 | busLog, objPath, entryId, |
| 238 | ms, // Milliseconds since 1970 |
| 239 | errLvl, std::move(errMsg), std::move(additionalData), |
| 240 | std::move(objects), fwVersion, getEntrySerializePath(entryId), *this); |
| 241 | |
| 242 | serialize(*e); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 243 | |
Matt Spinler | 601b811 | 2022-01-26 13:18:04 -0600 | [diff] [blame] | 244 | if (isQuiesceOnErrorEnabled() && (errLvl < Entry::sevLowerLimit) && |
| 245 | isCalloutPresent(*e)) |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 246 | { |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 247 | quiesceOnError(entryId); |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 248 | } |
| 249 | |
Adriana Kobylak | e7d271a | 2020-12-07 14:32:44 -0600 | [diff] [blame] | 250 | // Add entry before calling the extensions so that they have access to it |
| 251 | entries.insert(std::make_pair(entryId, std::move(e))); |
| 252 | |
| 253 | doExtensionLogCreate(*entries.find(entryId)->second, ffdc); |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 254 | |
| 255 | // Note: No need to close the file descriptors in the FFDC. |
Adriana Kobylak | 1db1bd3 | 2016-10-10 11:39:20 -0500 | [diff] [blame] | 256 | } |
| 257 | |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 258 | bool Manager::isQuiesceOnErrorEnabled() |
| 259 | { |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 260 | // When running under tests, the Logging.Settings service will not be |
| 261 | // present. Assume false. |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 262 | if (IS_UNIT_TEST) |
| 263 | { |
| 264 | return false; |
| 265 | } |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 266 | |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 267 | std::variant<bool> property; |
| 268 | |
| 269 | auto method = this->busLog.new_method_call( |
| 270 | "xyz.openbmc_project.Settings", "/xyz/openbmc_project/logging/settings", |
| 271 | "org.freedesktop.DBus.Properties", "Get"); |
| 272 | |
| 273 | method.append("xyz.openbmc_project.Logging.Settings", "QuiesceOnHwError"); |
| 274 | |
| 275 | try |
| 276 | { |
| 277 | auto reply = this->busLog.call(method); |
| 278 | reply.read(property); |
| 279 | } |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 280 | catch (const sdbusplus::exception_t& e) |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 281 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 282 | lg2::error("Error reading QuiesceOnHwError property: {ERROR}", "ERROR", |
| 283 | e); |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 284 | throw; |
| 285 | } |
| 286 | |
| 287 | return std::get<bool>(property); |
| 288 | } |
| 289 | |
Andrew Geissler | e4960ee | 2020-03-30 14:31:52 -0500 | [diff] [blame] | 290 | bool Manager::isCalloutPresent(const Entry& entry) |
| 291 | { |
| 292 | for (const auto& c : entry.additionalData()) |
| 293 | { |
| 294 | if (c.find("CALLOUT_") != std::string::npos) |
| 295 | { |
| 296 | return true; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return false; |
| 301 | } |
| 302 | |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 303 | void Manager::findAndRemoveResolvedBlocks() |
| 304 | { |
| 305 | for (auto& entry : entries) |
| 306 | { |
| 307 | if (entry.second->resolved()) |
| 308 | { |
| 309 | checkAndRemoveBlockingError(entry.first); |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 314 | void Manager::onEntryResolve(sdbusplus::message_t& msg) |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 315 | { |
| 316 | using Interface = std::string; |
| 317 | using Property = std::string; |
| 318 | using Value = std::string; |
Patrick Williams | 25acc6c | 2020-06-02 11:05:34 -0500 | [diff] [blame] | 319 | using Properties = std::map<Property, std::variant<Value>>; |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 320 | |
| 321 | Interface interface; |
| 322 | Properties properties; |
| 323 | |
| 324 | msg.read(interface, properties); |
| 325 | |
| 326 | for (const auto& p : properties) |
| 327 | { |
| 328 | if (p.first == "Resolved") |
| 329 | { |
| 330 | findAndRemoveResolvedBlocks(); |
| 331 | return; |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 336 | void Manager::checkAndQuiesceHost() |
| 337 | { |
Patrick Williams | a144a27 | 2021-07-16 17:03:55 -0500 | [diff] [blame] | 338 | using Host = sdbusplus::xyz::openbmc_project::State::server::Host; |
| 339 | |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 340 | // First check host state |
Patrick Williams | a144a27 | 2021-07-16 17:03:55 -0500 | [diff] [blame] | 341 | std::variant<Host::HostState> property; |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 342 | |
| 343 | auto method = this->busLog.new_method_call( |
| 344 | "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0", |
| 345 | "org.freedesktop.DBus.Properties", "Get"); |
| 346 | |
| 347 | method.append("xyz.openbmc_project.State.Host", "CurrentHostState"); |
| 348 | |
| 349 | try |
| 350 | { |
| 351 | auto reply = this->busLog.call(method); |
| 352 | reply.read(property); |
| 353 | } |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 354 | catch (const sdbusplus::exception_t& e) |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 355 | { |
| 356 | // Quiescing the host is a "best effort" type function. If unable to |
| 357 | // read the host state or it comes back empty, just return. |
| 358 | // The boot block object will still be created and the associations to |
| 359 | // find the log will be present. Don't want a dependency with |
| 360 | // phosphor-state-manager service |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 361 | lg2::info("Error reading QuiesceOnHwError property: {ERROR}", "ERROR", |
| 362 | e); |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 363 | return; |
| 364 | } |
| 365 | |
Patrick Williams | a144a27 | 2021-07-16 17:03:55 -0500 | [diff] [blame] | 366 | auto hostState = std::get<Host::HostState>(property); |
| 367 | if (hostState != Host::HostState::Running) |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 368 | { |
| 369 | return; |
| 370 | } |
| 371 | |
| 372 | auto quiesce = this->busLog.new_method_call( |
| 373 | "org.freedesktop.systemd1", "/org/freedesktop/systemd1", |
| 374 | "org.freedesktop.systemd1.Manager", "StartUnit"); |
| 375 | |
Andrew Geissler | 86a60e9 | 2022-04-15 14:36:02 -0500 | [diff] [blame] | 376 | quiesce.append("obmc-host-graceful-quiesce@0.target"); |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 377 | quiesce.append("replace"); |
| 378 | |
| 379 | this->busLog.call_noreply(quiesce); |
| 380 | } |
| 381 | |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 382 | void Manager::quiesceOnError(const uint32_t entryId) |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 383 | { |
Andrew Geissler | 72a1cca | 2020-09-10 16:49:09 -0500 | [diff] [blame] | 384 | // Verify we don't already have this entry blocking |
Matt Spinler | 4a37595 | 2022-07-01 11:15:33 -0500 | [diff] [blame] | 385 | auto it = find_if(this->blockingErrors.begin(), this->blockingErrors.end(), |
| 386 | [&](const std::unique_ptr<Block>& obj) { |
Patrick Williams | ac1ba3f | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 387 | return obj->entryId == entryId; |
| 388 | }); |
Andrew Geissler | 72a1cca | 2020-09-10 16:49:09 -0500 | [diff] [blame] | 389 | if (it != this->blockingErrors.end()) |
| 390 | { |
| 391 | // Already recorded so just return |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 392 | lg2::debug( |
Andrew Geissler | 72a1cca | 2020-09-10 16:49:09 -0500 | [diff] [blame] | 393 | "QuiesceOnError set and callout present but entry already logged"); |
| 394 | return; |
| 395 | } |
Andrew Geissler | e4960ee | 2020-03-30 14:31:52 -0500 | [diff] [blame] | 396 | |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 397 | lg2::info("QuiesceOnError set and callout present"); |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 398 | |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 399 | auto blockPath = std::string(OBJ_LOGGING) + "/block" + |
| 400 | std::to_string(entryId); |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 401 | auto blockObj = std::make_unique<Block>(this->busLog, blockPath, entryId); |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 402 | this->blockingErrors.push_back(std::move(blockObj)); |
| 403 | |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 404 | // Register call back if log is resolved |
| 405 | using namespace sdbusplus::bus::match::rules; |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 406 | auto entryPath = std::string(OBJ_ENTRY) + '/' + std::to_string(entryId); |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 407 | auto callback = std::make_unique<sdbusplus::bus::match_t>( |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 408 | this->busLog, |
| 409 | propertiesChanged(entryPath, "xyz.openbmc_project.Logging.Entry"), |
| 410 | std::bind(std::mem_fn(&Manager::onEntryResolve), this, |
| 411 | std::placeholders::_1)); |
| 412 | |
| 413 | propChangedEntryCallback.insert( |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 414 | std::make_pair(entryId, std::move(callback))); |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 415 | |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 416 | checkAndQuiesceHost(); |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 417 | } |
| 418 | |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 419 | void Manager::doExtensionLogCreate(const Entry& entry, const FFDCEntries& ffdc) |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 420 | { |
| 421 | // Make the association <endpointpath>/<endpointtype> paths |
| 422 | std::vector<std::string> assocs; |
| 423 | for (const auto& [forwardType, reverseType, endpoint] : |
| 424 | entry.associations()) |
| 425 | { |
| 426 | std::string e{endpoint}; |
| 427 | e += '/' + reverseType; |
| 428 | assocs.push_back(e); |
| 429 | } |
| 430 | |
| 431 | for (auto& create : Extensions::getCreateFunctions()) |
| 432 | { |
| 433 | try |
| 434 | { |
| 435 | create(entry.message(), entry.id(), entry.timestamp(), |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 436 | entry.severity(), entry.additionalData(), assocs, ffdc); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 437 | } |
Patrick Williams | 66491c6 | 2021-10-06 12:23:37 -0500 | [diff] [blame] | 438 | catch (const std::exception& e) |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 439 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 440 | lg2::error( |
| 441 | "An extension's create function threw an exception: {ERROR}", |
| 442 | "ERROR", e); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 443 | } |
| 444 | } |
| 445 | } |
| 446 | |
Patrick Williams | f40323d | 2021-04-16 15:35:17 -0500 | [diff] [blame] | 447 | void Manager::processMetadata(const std::string& /*errorName*/, |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 448 | const std::vector<std::string>& additionalData, |
| 449 | AssociationList& objects) const |
| 450 | { |
| 451 | // additionalData is a list of "metadata=value" |
| 452 | constexpr auto separator = '='; |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 453 | for (const auto& entryItem : additionalData) |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 454 | { |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 455 | auto found = entryItem.find(separator); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 456 | if (std::string::npos != found) |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 457 | { |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 458 | auto metadata = entryItem.substr(0, found); |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 459 | auto iter = meta.find(metadata); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 460 | if (meta.end() != iter) |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 461 | { |
| 462 | (iter->second)(metadata, additionalData, objects); |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 468 | void Manager::checkAndRemoveBlockingError(uint32_t entryId) |
| 469 | { |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 470 | // First look for blocking object and remove |
Matt Spinler | 4a37595 | 2022-07-01 11:15:33 -0500 | [diff] [blame] | 471 | auto it = find_if(blockingErrors.begin(), blockingErrors.end(), |
| 472 | [&](const std::unique_ptr<Block>& obj) { |
Patrick Williams | ac1ba3f | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 473 | return obj->entryId == entryId; |
| 474 | }); |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 475 | if (it != blockingErrors.end()) |
| 476 | { |
| 477 | blockingErrors.erase(it); |
| 478 | } |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 479 | |
| 480 | // Now remove the callback looking for the error to be resolved |
| 481 | auto resolveFind = propChangedEntryCallback.find(entryId); |
| 482 | if (resolveFind != propChangedEntryCallback.end()) |
| 483 | { |
| 484 | propChangedEntryCallback.erase(resolveFind); |
| 485 | } |
| 486 | |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 487 | return; |
| 488 | } |
| 489 | |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 490 | void Manager::erase(uint32_t entryId) |
| 491 | { |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 492 | auto entryFound = entries.find(entryId); |
| 493 | if (entries.end() != entryFound) |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 494 | { |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 495 | for (auto& func : Extensions::getDeleteProhibitedFunctions()) |
| 496 | { |
| 497 | try |
| 498 | { |
| 499 | bool prohibited = false; |
| 500 | func(entryId, prohibited); |
| 501 | if (prohibited) |
| 502 | { |
| 503 | // Future work remains to throw an error here. |
| 504 | return; |
| 505 | } |
| 506 | } |
Patrick Williams | 66491c6 | 2021-10-06 12:23:37 -0500 | [diff] [blame] | 507 | catch (const std::exception& e) |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 508 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 509 | lg2::error("An extension's deleteProhibited function threw an " |
| 510 | "exception: {ERROR}", |
| 511 | "ERROR", e); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 512 | } |
| 513 | } |
| 514 | |
Deepak Kodihalli | 3388799 | 2017-06-13 07:06:49 -0500 | [diff] [blame] | 515 | // Delete the persistent representation of this error. |
| 516 | fs::path errorPath(ERRLOG_PERSIST_PATH); |
Marri Devender Rao | 8959efc | 2017-11-17 00:13:41 -0600 | [diff] [blame] | 517 | errorPath /= std::to_string(entryId); |
Deepak Kodihalli | 3388799 | 2017-06-13 07:06:49 -0500 | [diff] [blame] | 518 | fs::remove(errorPath); |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 519 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 520 | auto removeId = [](std::list<uint32_t>& ids, uint32_t id) { |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 521 | auto it = std::find(ids.begin(), ids.end(), id); |
| 522 | if (it != ids.end()) |
| 523 | { |
| 524 | ids.erase(it); |
| 525 | } |
| 526 | }; |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 527 | if (entryFound->second->severity() >= Entry::sevLowerLimit) |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 528 | { |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 529 | removeId(infoErrors, entryId); |
| 530 | } |
| 531 | else |
| 532 | { |
| 533 | removeId(realErrors, entryId); |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 534 | } |
Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 535 | entries.erase(entryFound); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 536 | |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 537 | checkAndRemoveBlockingError(entryId); |
| 538 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 539 | for (auto& remove : Extensions::getDeleteFunctions()) |
| 540 | { |
| 541 | try |
| 542 | { |
| 543 | remove(entryId); |
| 544 | } |
Patrick Williams | 66491c6 | 2021-10-06 12:23:37 -0500 | [diff] [blame] | 545 | catch (const std::exception& e) |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 546 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 547 | lg2::error("An extension's delete function threw an exception: " |
| 548 | "{ERROR}", |
| 549 | "ERROR", e); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 550 | } |
| 551 | } |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 552 | } |
Marri Devender Rao | 8959efc | 2017-11-17 00:13:41 -0600 | [diff] [blame] | 553 | else |
| 554 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 555 | lg2::error("Invalid entry ID ({ID}) to delete", "ID", entryId); |
Marri Devender Rao | 8959efc | 2017-11-17 00:13:41 -0600 | [diff] [blame] | 556 | } |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 557 | } |
| 558 | |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 559 | void Manager::restore() |
| 560 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 561 | auto sanity = [](const auto& id, const auto& restoredId) { |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 562 | return id == restoredId; |
| 563 | }; |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 564 | |
| 565 | fs::path dir(ERRLOG_PERSIST_PATH); |
| 566 | if (!fs::exists(dir) || fs::is_empty(dir)) |
| 567 | { |
| 568 | return; |
| 569 | } |
| 570 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 571 | for (auto& file : fs::directory_iterator(dir)) |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 572 | { |
| 573 | auto id = file.path().filename().c_str(); |
| 574 | auto idNum = std::stol(id); |
| 575 | auto e = std::make_unique<Entry>( |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 576 | busLog, std::string(OBJ_ENTRY) + '/' + id, idNum, *this); |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 577 | if (deserialize(file.path(), *e)) |
| 578 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 579 | // validate the restored error entry id |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 580 | if (sanity(static_cast<uint32_t>(idNum), e->id())) |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 581 | { |
Matt Spinler | ef952af | 2021-08-19 10:23:05 -0500 | [diff] [blame] | 582 | e->path(file.path(), true); |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 583 | if (e->severity() >= Entry::sevLowerLimit) |
| 584 | { |
| 585 | infoErrors.push_back(idNum); |
| 586 | } |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 587 | else |
| 588 | { |
| 589 | realErrors.push_back(idNum); |
| 590 | } |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 591 | |
| 592 | entries.insert(std::make_pair(idNum, std::move(e))); |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 593 | } |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 594 | else |
| 595 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 596 | lg2::error( |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 597 | "Failed in sanity check while restoring error entry. " |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 598 | "Ignoring error entry {ID_NUM}/{ENTRY_ID}.", |
| 599 | "ID_NUM", idNum, "ENTRY_ID", e->id()); |
Marri Devender Rao | 979ed1c | 2017-11-17 05:06:25 -0600 | [diff] [blame] | 600 | } |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 601 | } |
| 602 | } |
| 603 | |
Lei YU | 01bf5c4 | 2022-05-23 15:33:23 +0800 | [diff] [blame] | 604 | if (!entries.empty()) |
Vishwanatha Subbanna | 37af9ba | 2017-09-28 16:33:53 +0530 | [diff] [blame] | 605 | { |
Lei YU | 01bf5c4 | 2022-05-23 15:33:23 +0800 | [diff] [blame] | 606 | entryId = entries.rbegin()->first; |
Vishwanatha Subbanna | 37af9ba | 2017-09-28 16:33:53 +0530 | [diff] [blame] | 607 | } |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 608 | } |
| 609 | |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 610 | std::string Manager::readFWVersion() |
| 611 | { |
Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 612 | auto version = util::getOSReleaseValue("VERSION_ID"); |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 613 | |
Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 614 | if (!version) |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 615 | { |
Patrick Williams | 5f285c5 | 2021-07-27 21:25:38 -0500 | [diff] [blame] | 616 | lg2::error("Unable to read BMC firmware version"); |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 617 | } |
| 618 | |
Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 619 | return version.value_or(""); |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 620 | } |
| 621 | |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 622 | void Manager::create(const std::string& message, Entry::Level severity, |
| 623 | const std::map<std::string, std::string>& additionalData) |
| 624 | { |
| 625 | // Convert the map into a vector of "key=value" strings |
| 626 | std::vector<std::string> ad; |
| 627 | metadata::associations::combine(additionalData, ad); |
| 628 | |
| 629 | createEntry(message, severity, ad); |
| 630 | } |
| 631 | |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 632 | void Manager::createWithFFDC( |
| 633 | const std::string& message, Entry::Level severity, |
| 634 | const std::map<std::string, std::string>& additionalData, |
| 635 | const FFDCEntries& ffdc) |
| 636 | { |
| 637 | // Convert the map into a vector of "key=value" strings |
| 638 | std::vector<std::string> ad; |
| 639 | metadata::associations::combine(additionalData, ad); |
| 640 | |
| 641 | createEntry(message, severity, ad, ffdc); |
| 642 | } |
| 643 | |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 644 | } // namespace internal |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 645 | } // namespace logging |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 646 | } // namespace phosphor |