Line data Source code
1 : /**
2 : * @file debug_speed.cxx - demonstrate debug message speed when Issues are used.
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : *
8 :
9 : Run:
10 : debug_speed
11 : or debug_speed 1 # this
12 : or DUNEDAQ_ERS_DEBUG_LEVEL=2 debug_speed
13 : or DUNEDAQ_ERS_DEBUG_LEVEL=2 debug_speed 1
14 : or TRACE_LVLS=-1 debug_speed
15 : or TRACE_LVLS=-1 debug_speed 1
16 : or TRACE_LVLS=-1 DUNEDAQ_ERS_DEBUG_LEVEL=2 debug_speed # or this
17 : */
18 :
19 : #include <logging/Logging.hpp>
20 : #include <string>
21 :
22 0 : ERS_DECLARE_ISSUE(ers, // namespace
23 : File2, // issue class name
24 : "simple message with file="<<file_name, // no message
25 : ((const char *)file_name ) // single attribute
26 : )
27 :
28 :
29 0 : int main(int argc, char *argv[] __attribute__((__unused__)))
30 : {
31 : // activate TRACE memory buffer for debugging
32 0 : std::string tfile="/tmp/trace_buffer_"+std::string(getenv("USER"))+"_debug_speed";
33 0 : system( ("rm -f "+tfile).c_str() );
34 0 : setenv("TRACE_FILE",tfile.c_str(),0);
35 :
36 0 : static const int dbglvl=1;
37 0 : setenv("TRACE_LVLM",std::to_string(1ULL<<(TLVL_DEBUG+dbglvl)).c_str(),0); // make sure the specific debug lvl used is enabled
38 :
39 0 : if (argc > 1) {
40 0 : dunedaq::logging::Logging::setup("test", "application"); // either do this or export DUNEDAQ_ERS_FATAL=erstrace,lstderr DUNEDAQ_ERS_ERROR='erstrace,throttle(30,100),lstderr' DUNEDAQ_ERS_WARNING='erstrace,throttle(30,100),lstderr'
41 : }
42 :
43 0 : ers::File2 efile2(ERS_HERE, "constructed file" );
44 :
45 0 : for (int ii=0; ii<10; ++ii)
46 0 : TLOG_DEBUG(dbglvl) << ers::File2( ERS_HERE, "construct file" );
47 :
48 0 : for (int ii=0; ii<10; ++ii)
49 0 : TLOG_DEBUG(dbglvl) << efile2;
50 :
51 0 : for (int ii=0; ii<10; ++ii)
52 0 : TLOG_DEBUG(dbglvl) << "message file does not exist";
53 :
54 0 : TLOG() << "\ntshow follows:\n\n";
55 0 : system( "TRACE_SHOW=\"%H%x%N %T %P %i %C %e %L %R %m\" trace_cntl show | trace_delta -ct 1 -d 1" );
56 :
57 0 : return (0);
58 0 : } // main
|