blob: 62b0574329c0c4ee903832bc848133cdce355eff [file] [log] [blame]
Claire Weinan919f71c2022-03-01 19:02:07 -08001#pragma once
2
3#include "dump_manager.hpp"
4
Claire Weinan919f71c2022-03-01 19:02:07 -08005#include <phosphor-logging/elog-errors.hpp>
6#include <phosphor-logging/elog.hpp>
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -05007#include <phosphor-logging/lg2.hpp>
Claire Weinan919f71c2022-03-01 19:02:07 -08008#include <sdbusplus/bus.hpp>
9#include <sdbusplus/server/object.hpp>
10#include <xyz/openbmc_project/Dump/Create/server.hpp>
11
12namespace phosphor
13{
14namespace dump
15{
16namespace faultlog
17{
18
19using namespace phosphor::logging;
20
Patrick Williams9b18bf22022-07-22 19:26:55 -050021using CreateIface = sdbusplus::server::object_t<
Claire Weinan919f71c2022-03-01 19:02:07 -080022 sdbusplus::xyz::openbmc_project::Dump::server::Create>;
23
24/** @class Manager
25 * @brief FaultLog Dump manager implementation.
26 */
27class Manager :
28 virtual public CreateIface,
29 virtual public phosphor::dump::Manager
30{
31 public:
32 Manager() = delete;
33 Manager(const Manager&) = default;
34 Manager& operator=(const Manager&) = delete;
35 Manager(Manager&&) = delete;
36 Manager& operator=(Manager&&) = delete;
37 virtual ~Manager() = default;
38
39 /** @brief Constructor to put object onto bus at a dbus path.
40 * @param[in] bus - Bus to attach to.
41 * @param[in] path - Path to attach at.
42 * @param[in] baseEntryPath - Base path for dump entry.
43 * @param[in] filePath - Path where the dumps are stored.
44 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050045 Manager(sdbusplus::bus_t& bus, const char* path,
Claire Weinan919f71c2022-03-01 19:02:07 -080046 const std::string& baseEntryPath, const char* filePath) :
47 CreateIface(bus, path),
48 phosphor::dump::Manager(bus, path, baseEntryPath), dumpDir(filePath)
49 {
50 std::error_code ec;
51
52 std::filesystem::create_directory(FAULTLOG_DUMP_PATH, ec);
53
54 if (ec)
55 {
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -050056 auto dir = FAULTLOG_DUMP_PATH;
57 lg2::error(
58 "dump_manager_faultlog directory {DIRECTORY} not created. "
59 "error_code = {ERRNO} ({ERROR_MESSAGE})",
60 "DIRECTORY", dir, "ERRNO", ec.value(), "ERROR_MESSAGE",
61 ec.message());
Claire Weinan919f71c2022-03-01 19:02:07 -080062 }
63 }
64
65 void restore() override
66 {
67 // TODO phosphor-debug-collector/issues/21: Restore fault log entries
68 // after service restart
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -050069 lg2::info("dump_manager_faultlog restore not implemented");
Claire Weinan919f71c2022-03-01 19:02:07 -080070 }
71
72 /** @brief Method to create a new fault log dump entry
73 * @param[in] params - Key-value pair input parameters
74 *
75 * @return object_path - The path to the new dump entry.
76 */
77 sdbusplus::message::object_path
78 createDump(phosphor::dump::DumpCreateParams params) override;
79
80 private:
81 /** @brief Path to the dump file*/
82 std::string dumpDir;
83};
84
85} // namespace faultlog
86} // namespace dump
87} // namespace phosphor