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