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_WARN__ <<
"WARNING: OTSDAQ_LOG_ROOT environment variable was not set!"
26 setenv(
"ARTDAQ_LOG_ROOT", logRootString, 1);
28 char* logFhiclCode = getenv(
"OTSDAQ_LOG_FHICL");
29 if(logFhiclCode ==
nullptr)
31 __COUT_WARN__ <<
"WARNING: OTSDAQ_LOG_FHICL environment variable was not set!"
37 setenv(
"ARTDAQ_LOG_FHICL", logFhiclCode, 1);
39 char* userDataString = getenv(
"USER_DATA");
40 if(userDataString ==
nullptr)
42 __SS__ <<
"ERROR: USER_DATA environment variable was not set!" << std::endl;
47 "DAQINTERFACE_MESSAGEFACILITY_FHICL",
48 (std::string(userDataString) +
49 "/MessageFacilityConfigurations/ARTDAQInterfaceMessageFacilityGen.fcl")
53 __COUT__ <<
"Configuring message facility with " << logFhiclCode << __E__;
57 FILE* fp = fopen(logFhiclCode,
"r");
58 unsigned int charCount = 0;
61 std::cout <<
"Message Facility fcl:" << __E__;
64 while(fgets(line, 100, fp))
67 charCount += strlen(line);
76 std::cout <<
"Retry - Was file really empty? " << logFhiclCode
79 fp = fopen(logFhiclCode,
"r");
85 artdaq::configureMessageFacility(name ,
89 artdaq::setMsgFacAppName(name, 0);
91 MESSAGE_FACILITY_INITIALIZED =
true;
void INIT_MF(const char *name)