blob: 5bc4882ce0b75637fd88b4c4aa1a18eaaa2d28fd [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 Kobylak88d7cf82017-01-24 12:30:15 -060010
11namespace phosphor
12{
13namespace logging
14{
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060015
Deepak Kodihallib388da62017-02-27 00:47:12 -060016using EntryIfaces = sdbusplus::server::object::object<
17 sdbusplus::xyz::openbmc_project::Logging::server::Entry,
Deepak Kodihalli36db46c2017-03-31 06:28:44 -050018 sdbusplus::xyz::openbmc_project::Object::server::Delete,
John Wang27d82812019-09-11 16:39:36 +080019 sdbusplus::xyz::openbmc_project::Association::server::Definitions,
Matt Spinler375ac9b2018-05-01 15:20:55 -050020 sdbusplus::xyz::openbmc_project::Software::server::Version>;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060021
Deepak Kodihalli35b46372017-02-27 04:58:18 -060022using AssociationList =
Patrick Venturef18bf832018-10-26 18:14:00 -070023 std::vector<std::tuple<std::string, std::string, std::string>>;
Deepak Kodihalli35b46372017-02-27 04:58:18 -060024
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050025namespace internal
26{
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050027class Manager;
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050028}
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050029
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060030/** @class Entry
31 * @brief OpenBMC logging entry implementation.
32 * @details A concrete implementation for the
Deepak Kodihallib388da62017-02-27 00:47:12 -060033 * xyz.openbmc_project.Logging.Entry and
John Wang27d82812019-09-11 16:39:36 +080034 * xyz.openbmc_project.Associations.Definitions DBus APIs.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060035 */
Deepak Kodihallib388da62017-02-27 00:47:12 -060036class Entry : public EntryIfaces
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060037{
Patrick Venturef18bf832018-10-26 18:14:00 -070038 public:
39 Entry() = delete;
40 Entry(const Entry&) = delete;
41 Entry& operator=(const Entry&) = delete;
42 Entry(Entry&&) = delete;
43 Entry& operator=(Entry&&) = delete;
44 virtual ~Entry() = default;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060045
Patrick Venturef18bf832018-10-26 18:14:00 -070046 /** @brief Constructor to put object onto bus at a dbus path.
47 * Defer signal registration (pass true for deferSignal to the
48 * base class) until after the properties are set.
49 * @param[in] bus - Bus to attach to.
50 * @param[in] path - Path to attach at.
51 * @param[in] idErr - The error entry id.
52 * @param[in] timestampErr - The commit timestamp.
53 * @param[in] severityErr - The severity of the error.
54 * @param[in] msgErr - The message of the error.
55 * @param[in] additionalDataErr - The error metadata.
56 * @param[in] objects - The list of associations.
57 * @param[in] fwVersion - The BMC code version.
58 * @param[in] parent - The error's parent.
59 */
60 Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t idErr,
61 uint64_t timestampErr, Level severityErr, std::string&& msgErr,
62 std::vector<std::string>&& additionalDataErr,
63 AssociationList&& objects, const std::string& fwVersion,
64 internal::Manager& parent) :
65 EntryIfaces(bus, path.c_str(), true),
66 parent(parent)
67 {
68 id(idErr);
69 severity(severityErr);
70 timestamp(timestampErr);
Matt Spinler1e71a4d2020-03-04 13:40:22 -060071 updateTimestamp(timestampErr);
Patrick Venturef18bf832018-10-26 18:14:00 -070072 message(std::move(msgErr));
73 additionalData(std::move(additionalDataErr));
74 associations(std::move(objects));
75 // Store a copy of associations in case we need to recreate
76 assocs = associations();
77 sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved(
78 false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060079
Patrick Venturef18bf832018-10-26 18:14:00 -070080 version(fwVersion);
81 purpose(VersionPurpose::BMC);
Matt Spinler375ac9b2018-05-01 15:20:55 -050082
Patrick Venturef18bf832018-10-26 18:14:00 -070083 // Emit deferred signal.
84 this->emit_object_added();
85 };
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060086
Patrick Venturef18bf832018-10-26 18:14:00 -070087 /** @brief Constructor that puts an "empty" error object on the bus,
88 * with only the id property populated. Rest of the properties
89 * to be set by the caller. Caller should emit the added signal.
90 * @param[in] bus - Bus to attach to.
91 * @param[in] path - Path to attach at.
92 * @param[in] id - The error entry id.
93 * @param[in] parent - The error's parent.
94 */
95 Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t entryId,
96 internal::Manager& parent) :
97 EntryIfaces(bus, path.c_str(), true),
98 parent(parent)
99 {
100 id(entryId);
101 };
Deepak Kodihalli72654f12017-06-12 04:33:29 -0500102
Patrick Venturef18bf832018-10-26 18:14:00 -0700103 /** @brief Set resolution status of the error.
104 * @param[in] value - boolean indicating resolution
105 * status (true = resolved)
106 * @returns value of 'Resolved' property
107 */
108 bool resolved(bool value) override;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500109
Patrick Venturef18bf832018-10-26 18:14:00 -0700110 using sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500111
Patrick Venturef18bf832018-10-26 18:14:00 -0700112 /** @brief Delete this d-bus object.
113 */
114 void delete_() override;
Deepak Kodihalli36db46c2017-03-31 06:28:44 -0500115
Patrick Venturef18bf832018-10-26 18:14:00 -0700116 /** @brief Severity level to check in cap.
117 * @details Errors with severity lesser than this will be
118 * considered as low priority and maximum ERROR_INFO_CAP
119 * number errors of this category will be captured.
120 */
121 static constexpr auto sevLowerLimit = Entry::Level::Informational;
Nagaraju Gorugantif8a5a792017-10-13 08:09:52 -0500122
Patrick Venturef18bf832018-10-26 18:14:00 -0700123 private:
124 /** @brief This entry's associations */
125 AssociationList assocs = {};
Deepak Kodihalli8110ca62017-04-10 02:11:54 -0500126
Patrick Venturef18bf832018-10-26 18:14:00 -0700127 /** @brief This entry's parent */
128 internal::Manager& parent;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -0600129};
130
131} // namespace logging
132} // namespace phosphor