1 #ifndef OTSDAQ_CORE_MESSAGEFACILITY_MESSAGEFACILITY_H
2 #define OTSDAQ_CORE_MESSAGEFACILITY_MESSAGEFACILITY_H
4 #include "otsdaq/Macros/CoutMacros.h"
6 #include <messagefacility/MessageLogger/MessageLogger.h>
7 #include "artdaq-core/Utilities/configureMessageFacility.hh"
11 static bool MESSAGE_FACILITY_INITIALIZED;
13 inline void INIT_MF(
const char* name)
15 if(MESSAGE_FACILITY_INITIALIZED)
18 char* logRootString = getenv(
"OTSDAQ_LOG_ROOT");
19 if(logRootString ==
nullptr)
21 __COUT_ERR__ <<
"\n**********************************************************" << std::endl;
22 __COUT_ERR__ <<
"WARNING: OTSDAQ_LOG_ROOT environment variable was not set!" << std::endl;
23 __COUT_ERR__ <<
"**********************************************************\n" << std::endl;
27 setenv(
"ARTDAQ_LOG_ROOT", logRootString, 1);
29 char* logFhiclCode = getenv(
"OTSDAQ_LOG_FHICL");
30 if(logFhiclCode ==
nullptr)
32 __COUT_ERR__ <<
"\n***********************************************************" << std::endl;
33 __COUT_ERR__ <<
"WARNING: OTSDAQ_LOG_FHICL environment variable was not set!" << std::endl;
34 __COUT_ERR__ <<
"***********************************************************\n" << std::endl;
39 setenv(
"ARTDAQ_LOG_FHICL", logFhiclCode, 1);
41 char* userDataString = getenv(
"USER_DATA");
42 if(userDataString ==
nullptr)
44 __COUT_ERR__ <<
"\n***********************************************************" << std::endl;
45 __COUT_ERR__ <<
"WARNING: USER_DATA environment variable was not set!" << std::endl;
46 __COUT_ERR__ <<
"***********************************************************\n" << std::endl;
47 __SS__ <<
"WARNING: USER_DATA environment variable was not set!" << std::endl;
51 setenv(
"DAQINTERFACE_MESSAGEFACILITY_FHICL",
52 (std::string(userDataString) +
"/MessageFacilityConfigurations/ARTDAQInterfaceMessageFacilityGen.fcl").c_str(),
56 __COUT__ <<
"Configuring message facility with " << logFhiclCode << __E__;
58 FILE* fp = fopen(logFhiclCode,
"r");
62 while(fgets(line, 100, fp))
69 artdaq::configureMessageFacility(name ,
false ,
true );
71 artdaq::setMsgFacAppName(name, 0);
73 MESSAGE_FACILITY_INITIALIZED =
true;