otsdaq  v2_01_00
MessageFacility.h
1 #ifndef OTSDAQ_CORE_MESSAGEFACILITY_MESSAGEFACILITY_H
2 #define OTSDAQ_CORE_MESSAGEFACILITY_MESSAGEFACILITY_H
3 
4 #include <messagefacility/MessageLogger/MessageLogger.h>
5 #include "artdaq-core/Utilities/configureMessageFacility.hh"
6 #include "otsdaq-core/Macros/CoutMacros.h"
7 
8 
9 namespace ots
10 {
11 
12 inline void INIT_MF(const char* name)
13 {
14  char* logRootString = getenv("OTSDAQ_LOG_ROOT");
15  if (logRootString == nullptr)
16  {
17 
18  __COUT_ERR__ << "\n**********************************************************" << std::endl;
19  __COUT_ERR__ << "WARNING: OTSDAQ_LOG_ROOT environment variable was not set!" << std::endl;
20  __COUT_ERR__ << "**********************************************************\n" << std::endl;;
21  //exit(0);
22  }
23  else
24  setenv("ARTDAQ_LOG_ROOT", logRootString, 1);
25 
26  char* logFhiclCode = getenv("OTSDAQ_LOG_FHICL");
27  if (logFhiclCode == nullptr)
28  {
29  __COUT_ERR__ << "\n***********************************************************" << std::endl;
30  __COUT_ERR__ << "WARNING: OTSDAQ_LOG_FHICL environment variable was not set!" << std::endl;
31  __COUT_ERR__ << "***********************************************************\n" << std::endl;
32  //exit(0);
33  }
34  else
35  setenv("ARTDAQ_LOG_FHICL", logFhiclCode, 1);
36 
37  artdaq::configureMessageFacility(
38  name /*application name*/,
39  false /*cout display*/,
40  true /*enable debug messages*/);
41 
42  artdaq::setMsgFacAppName(name,0);
43 }
44 
45 
46 }
47 
48 #endif