Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 1 | #include "config.h" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 2 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 3 | #include "extensions.hpp" |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 4 | #include "log_manager.hpp" |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 5 | |
Patrick Williams | 331c485 | 2021-04-16 15:38:59 -0500 | [diff] [blame] | 6 | #include <filesystem> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> |
| 8 | #include <sdbusplus/server/manager.hpp> |
Matt Spinler | 8ebfd31 | 2019-06-03 12:43:59 -0500 | [diff] [blame] | 9 | #include <sdeventplus/event.hpp> |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 10 | |
William A. Kennington III | b6b2557 | 2021-05-19 17:09:41 -0700 | [diff] [blame] | 11 | #include "config_main.h" |
| 12 | |
Patrick Williams | f40323d | 2021-04-16 15:35:17 -0500 | [diff] [blame] | 13 | int main(int /*argc*/, char* /*argv*/[]) |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 14 | { |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 15 | auto bus = sdbusplus::bus::new_default(); |
Matt Spinler | 8ebfd31 | 2019-06-03 12:43:59 -0500 | [diff] [blame] | 16 | auto event = sdeventplus::Event::get_default(); |
| 17 | bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL); |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 18 | |
Adriana Kobylak | 70bb6bc | 2017-02-21 19:51:52 -0600 | [diff] [blame] | 19 | // Add sdbusplus ObjectManager for the 'root' path of the logging manager. |
| 20 | sdbusplus::server::manager::manager objManager(bus, OBJ_LOGGING); |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 21 | |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 22 | phosphor::logging::internal::Manager iMgr(bus, OBJ_INTERNAL); |
| 23 | |
| 24 | phosphor::logging::Manager mgr(bus, OBJ_LOGGING, iMgr); |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 25 | |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 26 | // Create a directory to persist errors. |
Patrick Williams | 331c485 | 2021-04-16 15:38:59 -0500 | [diff] [blame] | 27 | std::filesystem::create_directories(ERRLOG_PERSIST_PATH); |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 28 | |
| 29 | // Recreate error d-bus objects from persisted errors. |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 30 | iMgr.restore(); |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 31 | |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 32 | bus.request_name(BUSNAME_LOGGING); |
| 33 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 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 | |
Matt Spinler | 8ebfd31 | 2019-06-03 12:43:59 -0500 | [diff] [blame] | 48 | return event.loop(); |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 49 | } |