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 const char *mf_test_config =
43 debugModules : [\"*\"]\n\
45 # threshold : DEBUG\n\
49 # type : Friendly # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
50 # threshold : DEBUG\n\
51 # #noLineBreaks : true\n\
52 # #lineLength : 200\n\
53 # #noTimeStamps : false\n\
54 # #useMilliseconds : true # this will short circuit format:timestamp:\n\
55 # #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
56 # resetStatistics : false\n\
58 # unimportant : { limit : 100 }\n\
59 # serious_matter : { limit : 1000 timespan : 60 }\n\
60 # default : { limit : 1000 }\n\
62 # format: { wantFullContext: true timestamp: \"%FT%T%z\" } #wantSomeContext: false }\n\
67 format: { timestamp: \"%FT%T%z\" }\n\
72 const char *mf_friendly_config =
74 debugModules : [\"*\"]\n\
76 # threshold : DEBUG\n\
80 type : Friendly # this is the important \"label\" -- value can be cout, cerr, or file (more with mf_extensions)\n\
82 #noLineBreaks : true\n\
84 #noTimeStamps : false\n\
85 #useMilliseconds : true # this will short circuit format:timestamp:\n\
86 #outputStatistics : true # this will cause exception if use by other than cout, cerr, or file\n\
87 resetStatistics : false\n\
89 unimportant : { limit : 100 }\n\
90 serious_matter : { limit : 1000 timespan : 60 }\n\
91 default : { limit : 1000 }\n\
93 format: { wantFullContext: true timestamp: \"%FT%T%z\" noLineBreaks: true} #wantSomeContext: false }\n\
98 format: { timestamp: \"%FT%T%z\" }\n\
103 const char *mf_TRACE_config =
105 debugModules : [\"*\"]\n\
107 # threshold : DEBUG\n\
113 format: { timestamp: \"%FT%T%z\" noLineBreaks: true}\n\
118 int main(
int argc,
char *argv[])
120 setenv(
"TRACE_MSG_MAX",
"0", 0);
121 setenv(
"TRACE_LIMIT_MS",
"5,50,500", 0);
123 fhicl::ParameterSet pset;
124 if (argc == 2 && strcmp(argv[1],
"test") == 0)
126 std::string pstr(mf_test_config);
127 fhicl::make_ParameterSet(pstr, pset);
130 else if (argc == 2 && strcmp(argv[1],
"TRACE") == 0)
132 std::string pstr(mf_TRACE_config);
133 fhicl::make_ParameterSet(pstr, pset);
136 else if (argc == 2 && strcmp(argv[1],
"friendly") == 0)
138 std::string pstr(mf_friendly_config);
139 fhicl::make_ParameterSet(pstr, pset);
145 setenv(
"FHICL_FILE_PATH",
".", 0);
146 cet::filepath_maker fpm;
147 fhicl::make_ParameterSet(argv[1], fpm, pset);
149 #if defined(__cplusplus) && (__cplusplus == 201300L)
150 mf::StartMessageFacility(mf::MessageFacilityService::MultiThread, pset);
151 mf::SetApplicationName(std::string(
"myAppName"));
153 mf::StartMessageFacility(pset);
155 mf::SetApplicationName(std::string(
"myAppName"));
160 TRACE(1,
"\nHello\n");
161 TLOG_ERROR(
"mf_test_category") <<
"hello - this is an mf::LogError(\"mf_test_category\")\n";
162 mf::LogAbsolute(
"abs_category/id") <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
163 mf::LogAbsolute(
"abs_category/id", __FILE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
164 mf::LogAbsolute(
"abs_category/id", __FILE__, __LINE__) <<
"hello - this is an mf::LogAbsolute(\"abs_category/id\")";
166 TRACE(1,
"start 1000 LOG_DEBUG");
167 for (
auto ii = 0; ii < 1000; ++ii) TLOG_DEBUG(
"mf_test_category") <<
"this is a LOG_DEBUG " << ii;
169 TRACE(1,
"end LOG_DEBUG, start 1000 TRACE");
171 for (
auto ii = 0; ii < 1000; ++ii) TRACEN_(TRACE_NAME, 1,
"this is a TRACE_ " << ii);
172 TRACE(1,
"end TRACE");
174 for (
auto ii = 0; ii < 2; ++ii) ::mf::LogTrace{
"simply", __FILE__, __LINE__} <<
"this is a test";