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