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