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"
40 #define TRACE_NAME "mftest"
42 const char *mf_test_config =
44 debugModules : [\"*\"]\n\
46 # threshold : DEBUG\n\
50 # type : Friendly # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
51 # threshold : DEBUG\n\
52 # #noLineBreaks : true\n\
53 # #lineLength : 200\n\
54 # #noTimeStamps : false\n\
55 # #useMilliseconds : true # this will short circuit format:timestamp:\n\
56 # #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
57 # resetStatistics : false\n\
59 # unimportant : { limit : 100 }\n\
60 # serious_matter : { limit : 1000 timespan : 60 }\n\
61 # default : { limit : 1000 }\n\
63 # format: { wantFullContext: true timestamp: \"%FT%T%z\" } #wantSomeContext: false }\n\
68 format: { timestamp: \"%FT%T%z\" }\n\
73 const char *mf_friendly_config =
75 debugModules : [\"*\"]\n\
77 # threshold : DEBUG\n\
81 type : Friendly # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
83 #noLineBreaks : true\n\
85 #noTimeStamps : false\n\
86 #useMilliseconds : true # this will short circuit format:timestamp:\n\
87 #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
88 resetStatistics : false\n\
90 unimportant : { limit : 100 }\n\
91 serious_matter : { limit : 1000 timespan : 60 }\n\
92 default : { limit : 1000 }\n\
94 format: { wantFullContext: true timestamp: \"%FT%T%z\" noLineBreaks: true} #wantSomeContext: false }\n\
99 format: { timestamp: \"%FT%T%z\" }\n\
104 const char *mf_OTS_config =
106 debugModules : [\"*\"]\n\
108 # threshold : DEBUG\n\
112 type : OTS # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
114 #noLineBreaks : true\n\
116 #noTimeStamps : false\n\
117 #useMilliseconds : true # this will short circuit format:timestamp:\n\
118 #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
119 resetStatistics : false\n\
121 unimportant : { limit : 100 }\n\
122 serious_matter : { limit : 1000 timespan : 60 }\n\
123 default : { limit : 1000 }\n\
125 format: { wantFullContext: true timestamp: \"%FT%T%z\" noLineBreaks: true} #wantSomeContext: false }\n\
130 format: { timestamp: \"%FT%T%z\" }\n\
135 const char *mf_TRACE_config =
137 debugModules : [\"*\"]\n\
139 # threshold : DEBUG\n\
145 format: { timestamp: \"%FT%T%z\" noLineBreaks: true}\n\
150 int main(
int argc,
char *argv[])
152 setenv(
"TRACE_MSG_MAX",
"0", 0);
153 setenv(
"TRACE_LIMIT_MS",
"5,50,500", 0);
155 fhicl::ParameterSet pset;
156 if (argc == 2 && strcmp(argv[1],
"test") == 0)
158 pset = fhicl::ParameterSet::make(std::string(mf_test_config));
161 else if (argc == 2 && strcmp(argv[1],
"TRACE") == 0)
163 pset = fhicl::ParameterSet::make(std::string(mf_TRACE_config));
166 else if (argc == 2 && strcmp(argv[1],
"friendly") == 0)
168 pset = fhicl::ParameterSet::make(std::string(mf_friendly_config));
171 else if (argc == 2 && strcmp(argv[1],
"OTS") == 0)
173 pset = fhicl::ParameterSet::make(std::string(mf_OTS_config));
179 setenv(
"FHICL_FILE_PATH",
".", 0);
180 cet::filepath_maker fpm;
181 pset = fhicl::ParameterSet::make(argv[1], fpm);
183 #if defined(__cplusplus) && (__cplusplus == 201300L)
184 mf::StartMessageFacility(mf::MessageFacilityService::MultiThread, pset);
185 mf::SetApplicationName(std::string(
"myAppName"));
187 mf::StartMessageFacility(pset);
189 mf::SetApplicationName(std::string(
"myAppName"));
194 TRACE(1,
"\nHello\n");
195 TLOG_ERROR(
"mf_test_category") <<
"hello - this is an mf::LogError(\"mf_test_category\")\n";
196 mf::LogAbsolute(
"abs_category/id") <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
197 mf::LogAbsolute(
"abs_category/id", __FILE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
198 mf::LogAbsolute(
"abs_category/id", __FILE__, __LINE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
200 TRACE(1,
"start 1000 LOG_DEBUG");
201 for (
auto ii = 0; ii < 1000; ++ii)
203 TLOG_DEBUG(
"mf_test_category") <<
"this is a LOG_DEBUG " << ii;
206 TRACE(1,
"end LOG_DEBUG, start 1000 TRACE");
208 for (
auto ii = 0; ii < 1000; ++ii)
210 TRACEN_(TRACE_NAME, 1,
"this is a TRACE_ " << ii);
212 TRACE(1,
"end TRACE");
214 for (
auto ii = 0; ii < 2; ++ii)
216 ::mf::LogTrace{
"simply", __FILE__, __LINE__} <<
"this is a test";