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 "fhiclcpp/make_ParameterSet.h"
38 #include "messagefacility/MessageLogger/MessageLogger.h"
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 std::string pstr(mf_test_config);
160 fhicl::make_ParameterSet(pstr, pset);
163 else if (argc == 2 && strcmp(argv[1],
"TRACE") == 0)
165 std::string pstr(mf_TRACE_config);
166 fhicl::make_ParameterSet(pstr, pset);
169 else if (argc == 2 && strcmp(argv[1],
"friendly") == 0)
171 std::string pstr(mf_friendly_config);
172 fhicl::make_ParameterSet(pstr, pset);
175 else if (argc == 2 && strcmp(argv[1],
"OTS") == 0)
177 std::string pstr(mf_OTS_config);
178 fhicl::make_ParameterSet(pstr, pset);
184 setenv(
"FHICL_FILE_PATH",
".", 0);
185 cet::filepath_maker fpm;
186 fhicl::make_ParameterSet(argv[1], fpm, pset);
188 #if defined(__cplusplus) && (__cplusplus == 201300L)
189 mf::StartMessageFacility(mf::MessageFacilityService::MultiThread, pset);
190 mf::SetApplicationName(std::string(
"myAppName"));
192 mf::StartMessageFacility(pset);
194 mf::SetApplicationName(std::string(
"myAppName"));
199 TRACE(1,
"\nHello\n");
200 TLOG_ERROR(
"mf_test_category") <<
"hello - this is an mf::LogError(\"mf_test_category\")\n";
201 mf::LogAbsolute(
"abs_category/id") <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
202 mf::LogAbsolute(
"abs_category/id", __FILE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
203 mf::LogAbsolute(
"abs_category/id", __FILE__, __LINE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
205 TRACE(1,
"start 1000 LOG_DEBUG");
206 for (
auto ii = 0; ii < 1000; ++ii)
208 TLOG_DEBUG(
"mf_test_category") <<
"this is a LOG_DEBUG " << ii;
211 TRACE(1,
"end LOG_DEBUG, start 1000 TRACE");
213 for (
auto ii = 0; ii < 1000; ++ii)
215 TRACEN_(TRACE_NAME, 1,
"this is a TRACE_ " << ii);
217 TRACE(1,
"end TRACE");
219 for (
auto ii = 0; ii < 2; ++ii)
221 ::mf::LogTrace{
"simply", __FILE__, __LINE__} <<
"this is a test";