blob: 9c93afe45af2390672690e7662fdce7ad4a77e13 [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);
71 message(std::move(msgErr));
72 additionalData(std::move(additionalDataErr));
73 associations(std::move(objects));
74 // Store a copy of associations in case we need to recreate
75 assocs = associations();
76 sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved(
77 false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060078
Patrick Venturef18bf832018-10-26 18:14:00 -070079 version(fwVersion);
80 purpose(VersionPurpose::BMC);
Matt Spinler375ac9b2018-05-01 15:20:55 -050081
Patrick Venturef18bf832018-10-26 18:14:00 -070082 // Emit deferred signal.
83 this->emit_object_added();
84 };
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060085
Patrick Venturef18bf832018-10-26 18:14:00 -070086 /** @brief Constructor that puts an "empty" error object on the bus,
87 * with only the id property populated. Rest of the properties
88 * to be set by the caller. Caller should emit the added signal.
89 * @param[in] bus - Bus to attach to.
90 * @param[in] path - Path to attach at.
91 * @param[in] id - The error entry id.
92 * @param[in] parent - The error's parent.
93 */
94 Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t entryId,
95 internal::Manager& parent) :
96 EntryIfaces(bus, path.c_str(), true),
97 parent(parent)
98 {
99 id(entryId);
100 };
Deepak Kodihalli72654f12017-06-12 04:33:29 -0500101
Patrick Venturef18bf832018-10-26 18:14:00 -0700102 /** @brief Set resolution status of the error.
103 * @param[in] value - boolean indicating resolution
104 * status (true = resolved)
105 * @returns value of 'Resolved' property
106 */
107 bool resolved(bool value) override;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500108
Patrick Venturef18bf832018-10-26 18:14:00 -0700109 using sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500110
Patrick Venturef18bf832018-10-26 18:14:00 -0700111 /** @brief Delete this d-bus object.
112 */
113 void delete_() override;
Deepak Kodihalli36db46c2017-03-31 06:28:44 -0500114
Patrick Venturef18bf832018-10-26 18:14:00 -0700115 /** @brief Severity level to check in cap.
116 * @details Errors with severity lesser than this will be
117 * considered as low priority and maximum ERROR_INFO_CAP
118 * number errors of this category will be captured.
119 */
120 static constexpr auto sevLowerLimit = Entry::Level::Informational;
Nagaraju Gorugantif8a5a792017-10-13 08:09:52 -0500121
Patrick Venturef18bf832018-10-26 18:14:00 -0700122 private:
123 /** @brief This entry's associations */
124 AssociationList assocs = {};
Deepak Kodihalli8110ca62017-04-10 02:11:54 -0500125
Patrick Venturef18bf832018-10-26 18:14:00 -0700126 /** @brief This entry's parent */
127 internal::Manager& parent;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -0600128};
129
130} // namespace logging
131} // namespace phosphor