blob: 59cbd540cb59c0919d4c1a600cd6d1c2ccbad035 [file] [log] [blame]
Adriana Kobylak8f7941e2016-11-14 14:46:23 -06001#include "config.h"
Patrick Venturef18bf832018-10-26 18:14:00 -07002
Matt Spinler99c2b402019-05-23 14:29:16 -05003#include "extensions.hpp"
Adriana Kobylak8f7941e2016-11-14 14:46:23 -06004#include "log_manager.hpp"
Adriana Kobylak8f7941e2016-11-14 14:46:23 -06005
Patrick Williams331c4852021-04-16 15:38:59 -05006#include <filesystem>
Patrick Venturef18bf832018-10-26 18:14:00 -07007#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/manager.hpp>
Matt Spinler8ebfd312019-06-03 12:43:59 -05009#include <sdeventplus/event.hpp>
Patrick Venturef18bf832018-10-26 18:14:00 -070010
William A. Kennington IIIb6b25572021-05-19 17:09:41 -070011#include "config_main.h"
12
Patrick Williamsf40323d2021-04-16 15:35:17 -050013int main(int /*argc*/, char* /*argv*/[])
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060014{
Adriana Kobylakf477fe22017-01-06 11:56:41 -060015 auto bus = sdbusplus::bus::new_default();
Matt Spinler8ebfd312019-06-03 12:43:59 -050016 auto event = sdeventplus::Event::get_default();
17 bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060018
Adriana Kobylak70bb6bc2017-02-21 19:51:52 -060019 // Add sdbusplus ObjectManager for the 'root' path of the logging manager.
20 sdbusplus::server::manager::manager objManager(bus, OBJ_LOGGING);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060021
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050022 phosphor::logging::internal::Manager iMgr(bus, OBJ_INTERNAL);
23
24 phosphor::logging::Manager mgr(bus, OBJ_LOGGING, iMgr);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060025
Deepak Kodihalli72654f12017-06-12 04:33:29 -050026 // Create a directory to persist errors.
Patrick Williams331c4852021-04-16 15:38:59 -050027 std::filesystem::create_directories(ERRLOG_PERSIST_PATH);
Deepak Kodihalli72654f12017-06-12 04:33:29 -050028
29 // Recreate error d-bus objects from persisted errors.
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050030 iMgr.restore();
Deepak Kodihalli72654f12017-06-12 04:33:29 -050031
Adriana Kobylakf477fe22017-01-06 11:56:41 -060032 bus.request_name(BUSNAME_LOGGING);
33
Matt Spinler99c2b402019-05-23 14:29:16 -050034 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 Spinler8ebfd312019-06-03 12:43:59 -050048 return event.loop();
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060049}