1 #include "config.h" 2 3 #include "config_main.h" 4 5 #include "extensions.hpp" 6 #include "log_manager.hpp" 7 8 #include <phosphor-logging/lg2.hpp> 9 #include <sdbusplus/bus.hpp> 10 #include <sdbusplus/server/manager.hpp> 11 #include <sdeventplus/event.hpp> 12 13 #include <filesystem> 14 15 int main(int /*argc*/, char* /*argv*/[]) 16 { 17 PHOSPHOR_LOG2_USING_WITH_FLAGS; 18 19 auto bus = sdbusplus::bus::new_default(); 20 auto event = sdeventplus::Event::get_default(); 21 bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL); 22 23 // Add sdbusplus ObjectManager for the 'root' path of the logging manager. 24 sdbusplus::server::manager_t objManager(bus, OBJ_LOGGING); 25 26 phosphor::logging::internal::Manager iMgr(bus, OBJ_INTERNAL); 27 28 phosphor::logging::Manager mgr(bus, OBJ_LOGGING, iMgr); 29 30 // Create a directory to persist errors. 31 std::filesystem::create_directories(ERRLOG_PERSIST_PATH); 32 33 // Recreate error d-bus objects from persisted errors. 34 iMgr.restore(); 35 36 for (auto& startup : phosphor::logging::Extensions::getStartupFunctions()) 37 { 38 try 39 { 40 startup(iMgr); 41 } 42 catch (const std::exception& e) 43 { 44 error("An extension's startup function threw an exception: {ERROR}", 45 "ERROR", e); 46 } 47 } 48 49 bus.request_name(BUSNAME_LOGGING); 50 51 return event.loop(); 52 } 53