blob: b64e1ba787fb9b26778f6f39ddc255d0384188f4 [file] [log] [blame]
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06001#pragma once
2
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06003#include "xyz/openbmc_project/Logging/Entry/server.hpp"
Deepak Kodihalli36db46c2017-03-31 06:28:44 -05004#include "xyz/openbmc_project/Object/Delete/server.hpp"
Matt Spinler375ac9b2018-05-01 15:20:55 -05005#include "xyz/openbmc_project/Software/Version/server.hpp"
Patrick Venturef18bf832018-10-26 18:14:00 -07006
7#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
John Wang27d82812019-09-11 16:39:36 +08009#include <xyz/openbmc_project/Association/Definitions/server.hpp>
Adriana Kobylak1ff95ef2020-12-03 13:52:19 -060010#include <xyz/openbmc_project/Common/FilePath/server.hpp>
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060011
12namespace phosphor
13{
14namespace logging
15{
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060016
Deepak Kodihallib388da62017-02-27 00:47:12 -060017using EntryIfaces = sdbusplus::server::object::object<
18 sdbusplus::xyz::openbmc_project::Logging::server::Entry,
Deepak Kodihalli36db46c2017-03-31 06:28:44 -050019 sdbusplus::xyz::openbmc_project::Object::server::Delete,
John Wang27d82812019-09-11 16:39:36 +080020 sdbusplus::xyz::openbmc_project::Association::server::Definitions,
Adriana Kobylak1ff95ef2020-12-03 13:52:19 -060021 sdbusplus::xyz::openbmc_project::Software::server::Version,
22 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060023
Deepak Kodihalli35b46372017-02-27 04:58:18 -060024using AssociationList =
Patrick Venturef18bf832018-10-26 18:14:00 -070025 std::vector<std::tuple<std::string, std::string, std::string>>;
Deepak Kodihalli35b46372017-02-27 04:58:18 -060026
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050027namespace internal
28{
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050029class Manager;
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050030}
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050031
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060032/** @class Entry
33 * @brief OpenBMC logging entry implementation.
34 * @details A concrete implementation for the
Deepak Kodihallib388da62017-02-27 00:47:12 -060035 * xyz.openbmc_project.Logging.Entry and
John Wang27d82812019-09-11 16:39:36 +080036 * xyz.openbmc_project.Associations.Definitions DBus APIs.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060037 */
Deepak Kodihallib388da62017-02-27 00:47:12 -060038class Entry : public EntryIfaces
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060039{
Patrick Venturef18bf832018-10-26 18:14:00 -070040 public:
41 Entry() = delete;
42 Entry(const Entry&) = delete;
43 Entry& operator=(const Entry&) = delete;
44 Entry(Entry&&) = delete;
45 Entry& operator=(Entry&&) = delete;
46 virtual ~Entry() = default;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060047
Patrick Venturef18bf832018-10-26 18:14:00 -070048 /** @brief Constructor to put object onto bus at a dbus path.
49 * Defer signal registration (pass true for deferSignal to the
50 * base class) until after the properties are set.
51 * @param[in] bus - Bus to attach to.
52 * @param[in] path - Path to attach at.
53 * @param[in] idErr - The error entry id.
54 * @param[in] timestampErr - The commit timestamp.
55 * @param[in] severityErr - The severity of the error.
56 * @param[in] msgErr - The message of the error.
57 * @param[in] additionalDataErr - The error metadata.
58 * @param[in] objects - The list of associations.
59 * @param[in] fwVersion - The BMC code version.
60 * @param[in] parent - The error's parent.
61 */
62 Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t idErr,
63 uint64_t timestampErr, Level severityErr, std::string&& msgErr,
64 std::vector<std::string>&& additionalDataErr,
65 AssociationList&& objects, const std::string& fwVersion,
66 internal::Manager& parent) :
67 EntryIfaces(bus, path.c_str(), true),
68 parent(parent)
69 {
70 id(idErr);
71 severity(severityErr);
72 timestamp(timestampErr);
Matt Spinler1e71a4d2020-03-04 13:40:22 -060073 updateTimestamp(timestampErr);
Patrick Venturef18bf832018-10-26 18:14:00 -070074 message(std::move(msgErr));
75 additionalData(std::move(additionalDataErr));
76 associations(std::move(objects));
77 // Store a copy of associations in case we need to recreate
78 assocs = associations();
79 sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved(
80 false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060081
Patrick Venturef18bf832018-10-26 18:14:00 -070082 version(fwVersion);
83 purpose(VersionPurpose::BMC);
Matt Spinler375ac9b2018-05-01 15:20:55 -050084
Patrick Venturef18bf832018-10-26 18:14:00 -070085 // Emit deferred signal.
86 this->emit_object_added();
87 };
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060088
Patrick Venturef18bf832018-10-26 18:14:00 -070089 /** @brief Constructor that puts an "empty" error object on the bus,
90 * with only the id property populated. Rest of the properties
91 * to be set by the caller. Caller should emit the added signal.
92 * @param[in] bus - Bus to attach to.
93 * @param[in] path - Path to attach at.
94 * @param[in] id - The error entry id.
95 * @param[in] parent - The error's parent.
96 */
97 Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t entryId,
98 internal::Manager& parent) :
99 EntryIfaces(bus, path.c_str(), true),
100 parent(parent)
101 {
102 id(entryId);
103 };
Deepak Kodihalli72654f12017-06-12 04:33:29 -0500104
Patrick Venturef18bf832018-10-26 18:14:00 -0700105 /** @brief Set resolution status of the error.
106 * @param[in] value - boolean indicating resolution
107 * status (true = resolved)
108 * @returns value of 'Resolved' property
109 */
110 bool resolved(bool value) override;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500111
Patrick Venturef18bf832018-10-26 18:14:00 -0700112 using sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500113
Patrick Venturef18bf832018-10-26 18:14:00 -0700114 /** @brief Delete this d-bus object.
115 */
116 void delete_() override;
Deepak Kodihalli36db46c2017-03-31 06:28:44 -0500117
Patrick Venturef18bf832018-10-26 18:14:00 -0700118 /** @brief Severity level to check in cap.
119 * @details Errors with severity lesser than this will be
120 * considered as low priority and maximum ERROR_INFO_CAP
121 * number errors of this category will be captured.
122 */
123 static constexpr auto sevLowerLimit = Entry::Level::Informational;
Nagaraju Gorugantif8a5a792017-10-13 08:09:52 -0500124
Patrick Venturef18bf832018-10-26 18:14:00 -0700125 private:
126 /** @brief This entry's associations */
127 AssociationList assocs = {};
Deepak Kodihalli8110ca62017-04-10 02:11:54 -0500128
Patrick Venturef18bf832018-10-26 18:14:00 -0700129 /** @brief This entry's parent */
130 internal::Manager& parent;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -0600131};
132
133} // namespace logging
134} // namespace phosphor