blob: 5ee8f5fa0c3ac6f1b411b78ed115699655977f3d [file] [log] [blame]
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
5#include "xyz/openbmc_project/Logging/Entry/server.hpp"
Deepak Kodihalli36db46c2017-03-31 06:28:44 -05006#include "xyz/openbmc_project/Object/Delete/server.hpp"
Matt Spinler375ac9b2018-05-01 15:20:55 -05007#include "xyz/openbmc_project/Software/Version/server.hpp"
Deepak Kodihallib388da62017-02-27 00:47:12 -06008#include "org/openbmc/Associations/server.hpp"
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06009
10namespace phosphor
11{
12namespace logging
13{
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060014
Deepak Kodihallib388da62017-02-27 00:47:12 -060015using EntryIfaces = sdbusplus::server::object::object<
16 sdbusplus::xyz::openbmc_project::Logging::server::Entry,
Deepak Kodihalli36db46c2017-03-31 06:28:44 -050017 sdbusplus::xyz::openbmc_project::Object::server::Delete,
Matt Spinler375ac9b2018-05-01 15:20:55 -050018 sdbusplus::org::openbmc::server::Associations,
19 sdbusplus::xyz::openbmc_project::Software::server::Version>;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060020
Deepak Kodihalli35b46372017-02-27 04:58:18 -060021using AssociationList =
22 std::vector<std::tuple<std::string, std::string, std::string>>;
23
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050024namespace internal
25{
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050026class Manager;
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050027}
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050028
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060029/** @class Entry
30 * @brief OpenBMC logging entry implementation.
31 * @details A concrete implementation for the
Deepak Kodihallib388da62017-02-27 00:47:12 -060032 * xyz.openbmc_project.Logging.Entry and
33 * org.openbmc.Associations DBus APIs.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060034 */
Deepak Kodihallib388da62017-02-27 00:47:12 -060035class Entry : public EntryIfaces
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060036{
37 public:
38 Entry() = delete;
39 Entry(const Entry&) = delete;
40 Entry& operator=(const Entry&) = delete;
41 Entry(Entry&&) = delete;
42 Entry& operator=(Entry&&) = delete;
43 virtual ~Entry() = default;
44
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060045 /** @brief Constructor to put object onto bus at a dbus path.
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060046 * Defer signal registration (pass true for deferSignal to the
47 * base class) until after the properties are set.
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060048 * @param[in] bus - Bus to attach to.
49 * @param[in] path - Path to attach at.
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060050 * @param[in] idErr - The error entry id.
51 * @param[in] timestampErr - The commit timestamp.
52 * @param[in] severityErr - The severity of the error.
53 * @param[in] msgErr - The message of the error.
54 * @param[in] additionalDataErr - The error metadata.
Matt Spinler375ac9b2018-05-01 15:20:55 -050055 * @param[in] objects - The list of associations.
56 * @param[in] fwVersion - The BMC code version.
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050057 * @param[in] parent - The error's parent.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060058 */
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060059 Entry(sdbusplus::bus::bus& bus,
60 const std::string& path,
61 uint32_t idErr,
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060062 uint64_t timestampErr,
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060063 Level severityErr,
64 std::string&& msgErr,
Deepak Kodihalli35b46372017-02-27 04:58:18 -060065 std::vector<std::string>&& additionalDataErr,
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050066 AssociationList&& objects,
Matt Spinler375ac9b2018-05-01 15:20:55 -050067 const std::string& fwVersion,
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050068 internal::Manager& parent) :
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050069 EntryIfaces(bus, path.c_str(), true),
70 parent(parent)
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060071 {
72 id(idErr);
73 severity(severityErr);
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060074 timestamp(timestampErr);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060075 message(std::move(msgErr));
76 additionalData(std::move(additionalDataErr));
Deepak Kodihalli35b46372017-02-27 04:58:18 -060077 associations(std::move(objects));
Deepak Kodihalli16aed112017-03-31 00:11:46 -050078 // Store a copy of associations in case we need to recreate
79 assocs = associations();
Deepak Kodihalli97431892017-06-12 09:14:57 -050080 sdbusplus::xyz::openbmc_project::
81 Logging::server::Entry::resolved(false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060082
Matt Spinler375ac9b2018-05-01 15:20:55 -050083 version(fwVersion);
84 purpose(VersionPurpose::BMC);
85
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060086 // Emit deferred signal.
87 this->emit_object_added();
88 };
89
Deepak Kodihalli72654f12017-06-12 04:33:29 -050090 /** @brief Constructor that puts an "empty" error object on the bus,
91 * with only the id property populated. Rest of the properties
92 * to be set by the caller. Caller should emit the added signal.
93 * @param[in] bus - Bus to attach to.
94 * @param[in] path - Path to attach at.
95 * @param[in] id - The error entry id.
96 * @param[in] parent - The error's parent.
97 */
98 Entry(sdbusplus::bus::bus& bus,
99 const std::string& path,
100 uint32_t entryId,
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -0500101 internal::Manager& parent) :
Deepak Kodihalli72654f12017-06-12 04:33:29 -0500102 EntryIfaces(bus, path.c_str(), true),
103 parent(parent)
104 {
105 id(entryId);
106 };
107
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500108 /** @brief Set resolution status of the error.
109 * @param[in] value - boolean indicating resolution
110 * status (true = resolved)
111 * @returns value of 'Resolved' property
112 */
Deepak Kodihalli97431892017-06-12 09:14:57 -0500113 bool resolved(bool value) override;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500114
Deepak Kodihalli72654f12017-06-12 04:33:29 -0500115 using sdbusplus::xyz::openbmc_project::
116 Logging::server::Entry::resolved;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500117
Deepak Kodihalli36db46c2017-03-31 06:28:44 -0500118 /** @brief Delete this d-bus object.
119 */
120 void delete_() override;
121
Nagaraju Gorugantif8a5a792017-10-13 08:09:52 -0500122 /** @brief Severity level to check in cap.
123 * @details Errors with severity lesser than this will be
124 * considered as low priority and maximum ERROR_INFO_CAP
125 * number errors of this category will be captured.
126 */
127 static constexpr auto sevLowerLimit = Entry::Level::Informational;
128
Deepak Kodihalli16aed112017-03-31 00:11:46 -0500129 private:
130 /** @brief This entry's associations */
131 AssociationList assocs = {};
Deepak Kodihalli8110ca62017-04-10 02:11:54 -0500132
133 /** @brief This entry's parent */
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -0500134 internal::Manager& parent;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -0600135};
136
137} // namespace logging
138} // namespace phosphor