Line data Source code
1 : /**
2 : * @file OpMonFacility.hpp
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "opmonlib/OpMonFacility.hpp"
10 : #include "logging/Logging.hpp"
11 :
12 : using namespace dunedaq::opmonlib;
13 :
14 : std::shared_ptr<OpMonFacility>
15 17 : dunedaq::opmonlib::makeOpMonFacility(std::string const& facility, OptionalOrigin o)
16 : {
17 :
18 34 : TLOG() << "FACILITY = " << facility;
19 :
20 17 : const std::string hook = "://";
21 17 : auto sep = facility.find(hook);
22 17 : std::string scheme;
23 17 : if (sep == std::string::npos) { // simple path
24 2 : scheme = "stdout";
25 : } else { // with scheme
26 15 : scheme = facility.substr(0, sep);
27 : }
28 :
29 17 : std::string plugin_name = scheme + "OpMonFacility";
30 20 : static cet::BasicPluginFactory bpf("duneOpMonFacility", "make");
31 17 : std::shared_ptr<OpMonFacility> os_ptr;
32 :
33 17 : try {
34 17 : os_ptr = bpf.makePlugin<std::shared_ptr<OpMonFacility>>(plugin_name, facility, o);
35 3 : } catch (const ers::Issue& iexpt) {
36 2 : throw OpMonFacilityCreationFailed(ERS_HERE, plugin_name, iexpt);
37 3 : } catch (const cet::exception& cexpt) {
38 1 : throw OpMonFacilityCreationFailedWithCause(ERS_HERE, plugin_name, cexpt.what());
39 1 : } catch (...) { // NOLINT JCF Jan-27-2021 violates letter of the law but not the spirit
40 0 : throw OpMonFacilityCreationFailed(ERS_HERE, plugin_name);
41 0 : }
42 14 : return os_ptr;
43 26 : }
|