1 #pragma once
2 
3 #include "elog_entry.hpp"
4 #include "log_manager.hpp"
5 
6 namespace openpower
7 {
8 namespace pels
9 {
10 
11 using namespace phosphor::logging;
12 
13 /**
14  * @brief PEL manager object
15  */
16 class Manager
17 {
18   public:
19     Manager() = delete;
20     ~Manager() = default;
21     Manager(const Manager&) = default;
22     Manager& operator=(const Manager&) = default;
23     Manager(Manager&&) = default;
24     Manager& operator=(Manager&&) = default;
25 
26     /**
27      * @brief constructor
28      *
29      * @param[in] logManager - internal::Manager object
30      */
31     explicit Manager(internal::Manager& logManager) : _logManager(logManager)
32     {
33     }
34 
35     /**
36      * @brief Creates a PEL based on the OpenBMC event log contents.  If
37      *        a PEL was passed in via the RAWPEL specifier in the
38      *        additionalData parameter, use that instead.
39      *
40      * @param[in] message - the event log message property
41      * @param[in] obmcLogID - the corresponding OpenBMC event log id
42      * @param[in] timestamp - the Timestamp property
43      * @param[in] severity - the event log severity
44      * @param[in] additionalData - the AdditionalData property
45      * @param[in] associations - the Associations property
46      */
47     void create(const std::string& message, uint32_t obmcLogID,
48                 uint64_t timestamp, Entry::Level severity,
49                 const std::vector<std::string>& additionalData,
50                 const std::vector<std::string>& associations);
51 
52     /**
53      * @brief Erase a PEL based on its OpenBMC event log ID
54      *
55      * @param[in] obmcLogID - the corresponding OpenBMC event log id
56      */
57     void erase(uint32_t obmcLogID);
58 
59     /** @brief Says if an OpenBMC event log may not be manually deleted at this
60      *         time because its corresponding PEL cannot be.
61      *
62      * There are PEL retention policies that can prohibit the manual deletion
63      * of PELs (and therefore OpenBMC event logs).
64      *
65      * @param[in] obmcLogID - the OpenBMC event log ID
66      * @return bool - true if prohibited
67      */
68     bool isDeleteProhibited(uint32_t obmcLogID);
69 
70   private:
71     /**
72      * @brief Adds a received raw PEL to the PEL repository
73      *
74      * @param[in] rawPelPath - The path to the file that contains the
75      *                         raw PEL.
76      * @param[in] obmcLogID - the corresponding OpenBMC event log id
77      */
78     void addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID);
79 
80     /**
81      * @brief Creates a PEL based on the OpenBMC event log contents.
82      *
83      * @param[in] message - The event log message property
84      * @param[in] obmcLogID - the corresponding OpenBMC event log id
85      * @param[in] timestamp - The timestamp property
86      * @param[in] severity - The event log severity
87      * @param[in] additionalData - The AdditionalData property
88      * @param[in] associations - The associations property
89      */
90     void createPEL(const std::string& message, uint32_t obmcLogID,
91                    uint64_t timestamp, Entry::Level severity,
92                    const std::vector<std::string>& additionalData,
93                    const std::vector<std::string>& associations);
94 
95     /**
96      * @brief Reference to phosphor-logging's Manager class
97      */
98     internal::Manager& _logManager;
99 };
100 
101 } // namespace pels
102 } // namespace openpower
103