blob: 42eb9829e5c9dcc366b7bd4f2c1197819706b3e5 [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 Venturef18bf832018-10-26 18:14:00 -07006#include <experimental/filesystem>
7#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
11int main(int argc, char* argv[])
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060012{
Adriana Kobylakf477fe22017-01-06 11:56:41 -060013 auto bus = sdbusplus::bus::new_default();
Matt Spinler8ebfd312019-06-03 12:43:59 -050014 auto event = sdeventplus::Event::get_default();
15 bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060016
Adriana Kobylak70bb6bc2017-02-21 19:51:52 -060017 // Add sdbusplus ObjectManager for the 'root' path of the logging manager.
18 sdbusplus::server::manager::manager objManager(bus, OBJ_LOGGING);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060019
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050020 phosphor::logging::internal::Manager iMgr(bus, OBJ_INTERNAL);
21
22 phosphor::logging::Manager mgr(bus, OBJ_LOGGING, iMgr);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060023
Deepak Kodihalli72654f12017-06-12 04:33:29 -050024 // 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 Goruganti05aae8b2017-08-30 07:56:12 -050028 iMgr.restore();
Deepak Kodihalli72654f12017-06-12 04:33:29 -050029
Adriana Kobylakf477fe22017-01-06 11:56:41 -060030 bus.request_name(BUSNAME_LOGGING);
31
Matt Spinler99c2b402019-05-23 14:29:16 -050032 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 Spinler8ebfd312019-06-03 12:43:59 -050046 return event.loop();
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060047}