blob: ddcb0631edb0195f5f37189d39a9b1af662ace5d [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>
9
10int main(int argc, char* argv[])
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060011{
Adriana Kobylakf477fe22017-01-06 11:56:41 -060012 auto bus = sdbusplus::bus::new_default();
13
Adriana Kobylak70bb6bc2017-02-21 19:51:52 -060014 // Add sdbusplus ObjectManager for the 'root' path of the logging manager.
15 sdbusplus::server::manager::manager objManager(bus, OBJ_LOGGING);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060016
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050017 phosphor::logging::internal::Manager iMgr(bus, OBJ_INTERNAL);
18
19 phosphor::logging::Manager mgr(bus, OBJ_LOGGING, iMgr);
Adriana Kobylakf477fe22017-01-06 11:56:41 -060020
Deepak Kodihalli72654f12017-06-12 04:33:29 -050021 // Create a directory to persist errors.
22 std::experimental::filesystem::create_directories(ERRLOG_PERSIST_PATH);
23
24 // Recreate error d-bus objects from persisted errors.
Nagaraju Goruganti05aae8b2017-08-30 07:56:12 -050025 iMgr.restore();
Deepak Kodihalli72654f12017-06-12 04:33:29 -050026
Adriana Kobylakf477fe22017-01-06 11:56:41 -060027 bus.request_name(BUSNAME_LOGGING);
28
Matt Spinler99c2b402019-05-23 14:29:16 -050029 for (auto& startup : phosphor::logging::Extensions::getStartupFunctions())
30 {
31 try
32 {
33 startup(iMgr);
34 }
35 catch (std::exception& e)
36 {
37 phosphor::logging::log<phosphor::logging::level::ERR>(
38 "An extension's startup function threw an exception",
39 phosphor::logging::entry("ERROR=%s", e.what()));
40 }
41 }
42
Patrick Venturef18bf832018-10-26 18:14:00 -070043 while (true)
Adriana Kobylakf477fe22017-01-06 11:56:41 -060044 {
45 bus.process_discard();
46 bus.wait();
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060047 }
Adriana Kobylakf477fe22017-01-06 11:56:41 -060048
49 return 0;
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060050}