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