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