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