blob: 8dcc2a2b6150517e214fe40d7861090cae552035 [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"
Deepak Kodihallib388da62017-02-27 00:47:12 -06007#include "org/openbmc/Associations/server.hpp"
Adriana Kobylak88d7cf82017-01-24 12:30:15 -06008
9namespace phosphor
10{
11namespace logging
12{
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060013
Deepak Kodihallib388da62017-02-27 00:47:12 -060014using EntryIfaces = sdbusplus::server::object::object<
15 sdbusplus::xyz::openbmc_project::Logging::server::Entry,
Deepak Kodihalli36db46c2017-03-31 06:28:44 -050016 sdbusplus::xyz::openbmc_project::Object::server::Delete,
Deepak Kodihallib388da62017-02-27 00:47:12 -060017 sdbusplus::org::openbmc::server::Associations>;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060018
Deepak Kodihalli35b46372017-02-27 04:58:18 -060019using AssociationList =
20 std::vector<std::tuple<std::string, std::string, std::string>>;
21
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050022namespace internal
23{
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050024class Manager;
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050025}
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050026
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060027/** @class Entry
28 * @brief OpenBMC logging entry implementation.
29 * @details A concrete implementation for the
Deepak Kodihallib388da62017-02-27 00:47:12 -060030 * xyz.openbmc_project.Logging.Entry and
31 * org.openbmc.Associations DBus APIs.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060032 */
Deepak Kodihallib388da62017-02-27 00:47:12 -060033class Entry : public EntryIfaces
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060034{
35 public:
36 Entry() = delete;
37 Entry(const Entry&) = delete;
38 Entry& operator=(const Entry&) = delete;
39 Entry(Entry&&) = delete;
40 Entry& operator=(Entry&&) = delete;
41 virtual ~Entry() = default;
42
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060043 /** @brief Constructor to put object onto bus at a dbus path.
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060044 * Defer signal registration (pass true for deferSignal to the
45 * base class) until after the properties are set.
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060046 * @param[in] bus - Bus to attach to.
47 * @param[in] path - Path to attach at.
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060048 * @param[in] idErr - The error entry id.
49 * @param[in] timestampErr - The commit timestamp.
50 * @param[in] severityErr - The severity of the error.
51 * @param[in] msgErr - The message of the error.
52 * @param[in] additionalDataErr - The error metadata.
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050053 * @param[in] parent - The error's parent.
Adriana Kobylak88d7cf82017-01-24 12:30:15 -060054 */
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060055 Entry(sdbusplus::bus::bus& bus,
56 const std::string& path,
57 uint32_t idErr,
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060058 uint64_t timestampErr,
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060059 Level severityErr,
60 std::string&& msgErr,
Deepak Kodihalli35b46372017-02-27 04:58:18 -060061 std::vector<std::string>&& additionalDataErr,
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050062 AssociationList&& objects,
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050063 internal::Manager& parent) :
Deepak Kodihalli8110ca62017-04-10 02:11:54 -050064 EntryIfaces(bus, path.c_str(), true),
65 parent(parent)
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060066 {
67 id(idErr);
68 severity(severityErr);
Adriana Kobylakc5f0bbd2017-01-22 14:56:04 -060069 timestamp(timestampErr);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060070 message(std::move(msgErr));
71 additionalData(std::move(additionalDataErr));
Deepak Kodihalli35b46372017-02-27 04:58:18 -060072 associations(std::move(objects));
Deepak Kodihalli16aed112017-03-31 00:11:46 -050073 // Store a copy of associations in case we need to recreate
74 assocs = associations();
Deepak Kodihalli97431892017-06-12 09:14:57 -050075 sdbusplus::xyz::openbmc_project::
76 Logging::server::Entry::resolved(false);
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060077
78 // Emit deferred signal.
79 this->emit_object_added();
80 };
81
Deepak Kodihalli72654f12017-06-12 04:33:29 -050082 /** @brief Constructor that puts an "empty" error object on the bus,
83 * with only the id property populated. Rest of the properties
84 * to be set by the caller. Caller should emit the added signal.
85 * @param[in] bus - Bus to attach to.
86 * @param[in] path - Path to attach at.
87 * @param[in] id - The error entry id.
88 * @param[in] parent - The error's parent.
89 */
90 Entry(sdbusplus::bus::bus& bus,
91 const std::string& path,
92 uint32_t entryId,
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050093 internal::Manager& parent) :
Deepak Kodihalli72654f12017-06-12 04:33:29 -050094 EntryIfaces(bus, path.c_str(), true),
95 parent(parent)
96 {
97 id(entryId);
98 };
99
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500100 /** @brief Set resolution status of the error.
101 * @param[in] value - boolean indicating resolution
102 * status (true = resolved)
103 * @returns value of 'Resolved' property
104 */
Deepak Kodihalli97431892017-06-12 09:14:57 -0500105 bool resolved(bool value) override;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500106
Deepak Kodihalli72654f12017-06-12 04:33:29 -0500107 using sdbusplus::xyz::openbmc_project::
108 Logging::server::Entry::resolved;
Deepak Kodihalli90abed62017-03-27 03:56:44 -0500109
Deepak Kodihalli36db46c2017-03-31 06:28:44 -0500110 /** @brief Delete this d-bus object.
111 */
112 void delete_() override;
113
Nagaraju Gorugantif8a5a792017-10-13 08:09:52 -0500114 /** @brief Severity level to check in cap.
115 * @details Errors with severity lesser than this will be
116 * considered as low priority and maximum ERROR_INFO_CAP
117 * number errors of this category will be captured.
118 */
119 static constexpr auto sevLowerLimit = Entry::Level::Informational;
120
Deepak Kodihalli16aed112017-03-31 00:11:46 -0500121 private:
122 /** @brief This entry's associations */
123 AssociationList assocs = {};
Deepak Kodihalli8110ca62017-04-10 02:11:54 -0500124
125 /** @brief This entry's parent */
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -0500126 internal::Manager& parent;
Adriana Kobylak88d7cf82017-01-24 12:30:15 -0600127};
128
129} // namespace logging
130} // namespace phosphor