11 setup messagefacility v1_18_03 -q e10:debug # will setup deps (cetlib, boost, cetlib_except, fhiclcpp)
12 : optional:; setup artdaq_mfextensions v1_01_10 -qe10:debug:s47
17 : setup messagefacility v2_01_00 -q e14:debug
18 setup messagefacility v2_00_02 -q e14:debug
19 : optional:; setup artdaq_mfextensions v1_01_12 -qe14:debug:s50
21 setup messagefacility v2_02_03 -qe15:prof
22 setup artdaq_mfextensions v1_03_04 -qprof:e15:s67
25 g++ -g -Wall -I$MESSAGEFACILITY_INC -I$CETLIB_INC -I$CETLIB_EXCEPT_INC -I$FHICLCPP_INC \
28 -std=c++14 -o mf_cout_vs_TRACE_printf{,.cc} -L$MESSAGEFACILITY_LIB -L$FHICLCPP_LIB -L$CETLIB_LIB\
29 -lMF_MessageLogger -lfhiclcpp -lcetlib && \
30 ./mf_cout_vs_TRACE_printf test
35 #include "TRACE/tracemf.h"
36 #include "fhiclcpp/ParameterSet.h"
37 #include "messagefacility/MessageLogger/MessageLogger.h"
38 #include "mfextensions/Binaries/MakeParameterSet.hh"
41 #define TRACE_NAME "mftest"
43 const char *mf_test_config =
45 debugModules : [\"*\"]\n\
47 # threshold : DEBUG\n\
51 # type : Friendly # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
52 # threshold : DEBUG\n\
53 # #noLineBreaks : true\n\
54 # #lineLength : 200\n\
55 # #noTimeStamps : false\n\
56 # #useMilliseconds : true # this will short circuit format:timestamp:\n\
57 # #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
58 # resetStatistics : false\n\
60 # unimportant : { limit : 100 }\n\
61 # serious_matter : { limit : 1000 timespan : 60 }\n\
62 # default : { limit : 1000 }\n\
64 # format: { wantFullContext: true timestamp: \"%FT%T%z\" } #wantSomeContext: false }\n\
69 format: { timestamp: \"%FT%T%z\" }\n\
74 const char *mf_friendly_config =
76 debugModules : [\"*\"]\n\
78 # threshold : DEBUG\n\
82 type : Friendly # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
84 #noLineBreaks : true\n\
86 #noTimeStamps : false\n\
87 #useMilliseconds : true # this will short circuit format:timestamp:\n\
88 #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
89 resetStatistics : false\n\
91 unimportant : { limit : 100 }\n\
92 serious_matter : { limit : 1000 timespan : 60 }\n\
93 default : { limit : 1000 }\n\
95 format: { wantFullContext: true timestamp: \"%FT%T%z\" noLineBreaks: true} #wantSomeContext: false }\n\
100 format: { timestamp: \"%FT%T%z\" }\n\
105 const char *mf_OTS_config =
107 debugModules : [\"*\"]\n\
109 # threshold : DEBUG\n\
113 type : OTS # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
115 #noLineBreaks : true\n\
117 #noTimeStamps : false\n\
118 #useMilliseconds : true # this will short circuit format:timestamp:\n\
119 #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
120 resetStatistics : false\n\
122 unimportant : { limit : 100 }\n\
123 serious_matter : { limit : 1000 timespan : 60 }\n\
124 default : { limit : 1000 }\n\
126 format: { wantFullContext: true timestamp: \"%FT%T%z\" noLineBreaks: true} #wantSomeContext: false }\n\
131 format: { timestamp: \"%FT%T%z\" }\n\
136 const char *mf_TRACE_config =
138 debugModules : [\"*\"]\n\
140 # threshold : DEBUG\n\
146 format: { timestamp: \"%FT%T%z\" noLineBreaks: true}\n\
151 int main(
int argc,
char *argv[])
153 setenv(
"TRACE_MSG_MAX",
"0", 0);
154 setenv(
"TRACE_LIMIT_MS",
"5,50,500", 0);
156 fhicl::ParameterSet pset;
157 if (argc == 2 && strcmp(argv[1],
"test") == 0)
159 pset = artdaq::make_pset(std::string(mf_test_config));
162 else if (argc == 2 && strcmp(argv[1],
"TRACE") == 0)
164 pset = artdaq::make_pset(std::string(mf_TRACE_config));
167 else if (argc == 2 && strcmp(argv[1],
"friendly") == 0)
169 pset = artdaq::make_pset(std::string(mf_friendly_config));
172 else if (argc == 2 && strcmp(argv[1],
"OTS") == 0)
174 pset = artdaq::make_pset(std::string(mf_OTS_config));
180 setenv(
"FHICL_FILE_PATH",
".", 0);
181 cet::filepath_maker fpm;
182 pset = artdaq::make_pset(argv[1], fpm);
184 #if defined(__cplusplus) && (__cplusplus == 201300L)
185 mf::StartMessageFacility(mf::MessageFacilityService::MultiThread, pset);
186 mf::SetApplicationName(std::string(
"myAppName"));
188 mf::StartMessageFacility(pset);
190 mf::SetApplicationName(std::string(
"myAppName"));
195 TRACE(1,
"\nHello\n");
196 TLOG_ERROR(
"mf_test_category") <<
"hello - this is an mf::LogError(\"mf_test_category\")\n";
197 mf::LogAbsolute(
"abs_category/id") <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
198 mf::LogAbsolute(
"abs_category/id", __FILE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
199 mf::LogAbsolute(
"abs_category/id", __FILE__, __LINE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
201 TRACE(1,
"start 1000 LOG_DEBUG");
202 for (
auto ii = 0; ii < 1000; ++ii)
204 TLOG_DEBUG(
"mf_test_category") <<
"this is a LOG_DEBUG " << ii;
207 TRACE(1,
"end LOG_DEBUG, start 1000 TRACE");
209 for (
auto ii = 0; ii < 1000; ++ii)
211 TRACEN_(TRACE_NAME, 1,
"this is a TRACE_ " << ii);
213 TRACE(1,
"end TRACE");
215 for (
auto ii = 0; ii < 2; ++ii)
217 ::mf::LogTrace{
"simply", __FILE__, __LINE__} <<
"this is a test";