otsdaq  v2_03_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 namespace ots
9 {
10 inline void INIT_MF(const char* name)
11 {
12  char* logRootString = getenv("OTSDAQ_LOG_ROOT");
13  if(logRootString == nullptr)
14  {
15  __COUT_ERR__ << "\n**********************************************************"
16  << std::endl;
17  __COUT_ERR__ << "WARNING: OTSDAQ_LOG_ROOT environment variable was not set!"
18  << std::endl;
19  __COUT_ERR__ << "**********************************************************\n"
20  << std::endl;
21  ;
22  // exit(0);
23  }
24  else
25  setenv("ARTDAQ_LOG_ROOT", logRootString, 1);
26 
27  char* logFhiclCode = getenv("OTSDAQ_LOG_FHICL");
28  if(logFhiclCode == nullptr)
29  {
30  __COUT_ERR__ << "\n***********************************************************"
31  << std::endl;
32  __COUT_ERR__ << "WARNING: OTSDAQ_LOG_FHICL environment variable was not set!"
33  << std::endl;
34  __COUT_ERR__ << "***********************************************************\n"
35  << std::endl;
36  // exit(0);
37  }
38  else
39  setenv("ARTDAQ_LOG_FHICL", logFhiclCode, 1);
40 
41  __COUT__ << "Configuring message facility with " << logFhiclCode << __E__;
42  artdaq::configureMessageFacility(name /*application name*/,
43  false /*cout display*/,
44  true /*enable debug messages*/);
45 
46  artdaq::setMsgFacAppName(name, 0);
47 }
48 
49 } // namespace ots
50 
51 #endif