xref: /openbmc/phosphor-logging/elog_entry.hpp (revision 17944e13e5d00d17427b5d49c6e84dbfd0033b45)
1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 #include <sdbusplus/server/object.hpp>
5 #include "xyz/openbmc_project/Logging/Entry/server.hpp"
6 
7 namespace phosphor
8 {
9 namespace logging
10 {
11 namespace details
12 {
13 
14 template <typename T>
15 using ServerObject = typename sdbusplus::server::object::object<T>;
16 
17 using EntryIface =
18     sdbusplus::xyz::openbmc_project::Logging::server::Entry;
19 
20 } // namespace details
21 
22 /** @class Entry
23  *  @brief OpenBMC logging entry implementation.
24  *  @details A concrete implementation for the
25  *  xyz.openbmc_project.Logging.Entry DBus API.
26  */
27 class Entry : public details::ServerObject<details::EntryIface>
28 {
29     public:
30         Entry() = delete;
31         Entry(const Entry&) = delete;
32         Entry& operator=(const Entry&) = delete;
33         Entry(Entry&&) = delete;
34         Entry& operator=(Entry&&) = delete;
35         virtual ~Entry() = default;
36 
37         /** @brief Constructor to put object onto bus at a dbus path.
38          *         Defer signal registration (pass true for deferSignal to the
39          *         base class) until after the properties are set.
40          *  @param[in] bus - Bus to attach to.
41          *  @param[in] path - Path to attach at.
42          *  @param[in] idErr - The error entry id.
43          *  @param[in] timestampErr - The commit timestamp.
44          *  @param[in] severityErr - The severity of the error.
45          *  @param[in] msgErr - The message of the error.
46          *  @param[in] additionalDataErr - The error metadata.
47          */
48         Entry(sdbusplus::bus::bus& bus,
49               const std::string& path,
50               uint32_t idErr,
51               uint64_t timestampErr,
52               Level severityErr,
53               std::string&& msgErr,
54               std::vector<std::string>&& additionalDataErr) :
55               details::ServerObject<details::EntryIface>
56                     (bus, path.c_str(), true)
57         {
58             id(idErr);
59             severity(severityErr);
60             timestamp(timestampErr);
61             message(std::move(msgErr));
62             additionalData(std::move(additionalDataErr));
63 
64             // Emit deferred signal.
65             this->emit_object_added();
66         };
67 
68 };
69 
70 } // namespace logging
71 } // namespace phosphor
72