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;
15 if(MESSAGE_FACILITY_INITIALIZED)
18 char* logRootString = getenv(
"OTSDAQ_LOG_ROOT");
19 if(logRootString ==
nullptr)
21 __COUT_ERR__ <<
"\n**********************************************************"
23 __COUT_ERR__ <<
"WARNING: OTSDAQ_LOG_ROOT environment variable was not set!"
25 __COUT_ERR__ <<
"**********************************************************\n"
30 setenv(
"ARTDAQ_LOG_ROOT", logRootString, 1);
32 char* logFhiclCode = getenv(
"OTSDAQ_LOG_FHICL");
33 if(logFhiclCode ==
nullptr)
35 __COUT_ERR__ <<
"\n***********************************************************"
37 __COUT_ERR__ <<
"WARNING: OTSDAQ_LOG_FHICL environment variable was not set!"
39 __COUT_ERR__ <<
"***********************************************************\n"
45 setenv(
"ARTDAQ_LOG_FHICL", logFhiclCode, 1);
47 char* userDataString = getenv(
"USER_DATA");
48 if(userDataString ==
nullptr)
51 <<
"\n***********************************************************"
53 __COUT_ERR__ <<
"WARNING: USER_DATA environment variable was not set!"
56 <<
"***********************************************************\n"
58 __SS__ <<
"WARNING: USER_DATA environment variable was not set!" << std::endl;
63 "DAQINTERFACE_MESSAGEFACILITY_FHICL",
64 (std::string(userDataString) +
65 "/MessageFacilityConfigurations/ARTDAQInterfaceMessageFacilityGen.fcl")
70 __COUT__ <<
"Configuring message facility with " << logFhiclCode << __E__;
72 FILE* fp = fopen(logFhiclCode,
"r");
73 unsigned int charCount = 0;
78 while(fgets(line, 100, fp))
81 charCount += strlen(line);
90 std::cout <<
"Retry - Was file really empty? " << logFhiclCode << __E__;
92 fp = fopen(logFhiclCode,
"r");
96 artdaq::configureMessageFacility(name ,
100 artdaq::setMsgFacAppName(name, 0);
102 MESSAGE_FACILITY_INITIALIZED =
true;
void INIT_MF(const char *name)