From 0bdf54802a2ef34fb2f9aa99a07cec0888251d32 Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Mon, 25 Mar 2024 13:45:23 -0500 Subject: [PATCH 1/4] may not compile -- issues with /cvmfs on iceberg03 --- CMakeLists.txt | 1 + test/apps/ProgressUpdate.cxx | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/apps/ProgressUpdate.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 13c1f40..74e1530 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ daq_add_application( performance performance.cxx TEST LINK_LIBRARIES logging ) daq_add_application( six_streams six_streams.cxx TEST LINK_LIBRARIES logging ) daq_add_application( debug_speed debug_speed.cxx TEST LINK_LIBRARIES logging ) daq_add_application( multithreaded_warning_log multithreaded_warning_log.cxx TEST LINK_LIBRARIES logging ) +daq_add_application( ProgressUpdate.cxx TEST LINK_LIBRARIES logging ) daq_install() diff --git a/test/apps/ProgressUpdate.cxx b/test/apps/ProgressUpdate.cxx new file mode 100644 index 0000000..2941397 --- /dev/null +++ b/test/apps/ProgressUpdate.cxx @@ -0,0 +1,28 @@ +#ifndef DUNEDAQ_PACKAGE_NAME // this could/may be (tbd) set by the build system +# define DUNEDAQ_PACKAGE_NAME "Logging_" // becomes an ERS Qualifier +#endif +#include +#include + + +ERS_DECLARE_ISSUE_BASE(dfmodules, + ProgressUpdate, + appfwk::GeneralDAQModuleIssue, + message, + ((std::string)name), + ((std::string)message)) + + +int main(/*int argc, char *argv[]*/) +{ + setenv("DUNEDAQ_APPLICATION_NAME","LOGGING_PROGRESS_APP",0); + dunedaq::logging::Logging::setup(); // not strictly needed -- checks/establishes a default env. + + std::vector theList{1,2,3}; + std::ostringstream oss_prog; + oss_prog << "Generated list #" << 3 << " with contents " << theList + << " and size " << theList.size() << ". "; + TLOG() << (ProgressUpdate(ERS_HERE, get_name(), oss_prog.str())); + + return 0; +} From d5f8bccd43c9b934722d8eb72b6f1f00b9226378 Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Mon, 25 Mar 2024 14:44:32 -0500 Subject: [PATCH 2/4] cmake oops --- CMakeLists.txt | 2 +- test/apps/{ProgressUpdate.cxx => log_progress_update.cxx} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test/apps/{ProgressUpdate.cxx => log_progress_update.cxx} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74e1530..0c60ed0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ daq_add_application( performance performance.cxx TEST LINK_LIBRARIES logging ) daq_add_application( six_streams six_streams.cxx TEST LINK_LIBRARIES logging ) daq_add_application( debug_speed debug_speed.cxx TEST LINK_LIBRARIES logging ) daq_add_application( multithreaded_warning_log multithreaded_warning_log.cxx TEST LINK_LIBRARIES logging ) -daq_add_application( ProgressUpdate.cxx TEST LINK_LIBRARIES logging ) +daq_add_application( log_progress_update log_progress_update.cxx TEST LINK_LIBRARIES logging ) daq_install() diff --git a/test/apps/ProgressUpdate.cxx b/test/apps/log_progress_update.cxx similarity index 100% rename from test/apps/ProgressUpdate.cxx rename to test/apps/log_progress_update.cxx From 874c80e1082fef62b2b5a779525a5fd67ceba168 Mon Sep 17 00:00:00 2001 From: Kurt Biery Date: Mon, 25 Mar 2024 16:51:46 -0500 Subject: [PATCH 3/4] add Eric's stream operator --- test/apps/log_progress_update.cxx | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/test/apps/log_progress_update.cxx b/test/apps/log_progress_update.cxx index 2941397..aff3d16 100644 --- a/test/apps/log_progress_update.cxx +++ b/test/apps/log_progress_update.cxx @@ -3,26 +3,48 @@ #endif #include #include +#include +ERS_DECLARE_ISSUE(appfwk, ///< Namespace + GeneralDAQModuleIssue, ///< Issue class name + " DAQModule: " << name, ///< Message + ((std::string)name) ///< Message parameters +) -ERS_DECLARE_ISSUE_BASE(dfmodules, +ERS_DECLARE_ISSUE_BASE(logging, ProgressUpdate, appfwk::GeneralDAQModuleIssue, message, ((std::string)name), ((std::string)message)) +using namespace logging; + +std::ostream& +operator<<(std::ostream& t, std::vector ints) +{ + t << "{"; + bool first = true; + for (auto& i : ints) { + if (!first) + t << ", "; + first = false; + t << i; + } + return t << "}"; +} int main(/*int argc, char *argv[]*/) { setenv("DUNEDAQ_APPLICATION_NAME","LOGGING_PROGRESS_APP",0); dunedaq::logging::Logging::setup(); // not strictly needed -- checks/establishes a default env. + std::atomic m_generated_tot{ 3 }; std::vector theList{1,2,3}; std::ostringstream oss_prog; - oss_prog << "Generated list #" << 3 << " with contents " << theList + oss_prog << "Generated list #" << m_generated_tot.load() << " with contents " << theList << " and size " << theList.size() << ". "; - TLOG() << (ProgressUpdate(ERS_HERE, get_name(), oss_prog.str())); + TLOG_DEBUG() << (ProgressUpdate(ERS_HERE, "someName", oss_prog.str())); return 0; } From f07019e6a73bb90da17bd9d989274e5474867b3e Mon Sep 17 00:00:00 2001 From: Ron Rechenmacher Date: Wed, 3 Apr 2024 13:02:03 -0500 Subject: [PATCH 4/4] only include/logging/internal/macro.hpp is absolutely necessary --- docs/README.md | 2 +- include/logging/internal/macro.hpp | 12 ++++++++---- test/apps/basic_functionality_example.cxx | 4 ++-- test/apps/log_progress_update.cxx | 18 +++++++++++++++--- test/apps/multithreaded_warning_log.cxx | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docs/README.md b/docs/README.md index 16f0bfb..38f9857 100644 --- a/docs/README.md +++ b/docs/README.md @@ -41,7 +41,7 @@ Conventions and best practices for ERS issues in the DUNE DAQ software can be fo The above referenced conventions and best practices does not cover the use of the TRACE macros. -The TLOG() macro should used in cases similar to ers::info with the following 2 distinctions: 1) unstructed (non-ers::Issue) messages can be used and 2) logging will remain local, i.e. stdout only and not to a central/network logging facility. +The TLOG() macro should be used in cases similar to ers::info with the following 2 distinctions: 1) unstructed (non-ers::Issue) messages can be used and 2) logging will remain local, i.e. stdout only and not to a central/network logging facility. The TLOG_DEBUG(lvl) is to be used for messages which will be selectively enabled or disabled for debugging purposes. The lvl can be an arbitrary integer between 0 and 55. diff --git a/include/logging/internal/macro.hpp b/include/logging/internal/macro.hpp index 9c9ac35..acb95d7 100644 --- a/include/logging/internal/macro.hpp +++ b/include/logging/internal/macro.hpp @@ -45,7 +45,8 @@ # define ERS_DECLARE_ISSUE_BASE( namespace_name, class_name, base_class_name, message_, base_attributes, attributes ) \ __ERS_DECLARE_ISSUE_BASE__( namespace_name, class_name, base_class_name, message_, base_attributes, attributes ) \ __ERS_DEFINE_ISSUE_BASE__( inline, namespace_name, class_name, base_class_name, message_, base_attributes, attributes ) \ - static inline TraceStreamer& operator<<(TraceStreamer& x, const namespace_name::class_name &r) \ + namespace namespace_name { \ + static inline TraceStreamer& operator<<(TraceStreamer& x, const class_name &r) \ {if (x.do_m) {\ x.line_=r.context().line_number(); x.msg_append( r.message().c_str() );\ /* MAY NEED TO APPEND CHAINED ISSUE??? */ \ @@ -57,13 +58,15 @@ x.do_s = 0; \ } \ return x; \ - } + } \ + } # undef ERS_DECLARE_ISSUE # define ERS_DECLARE_ISSUE( namespace_name, class_name, message_, attributes ) \ __ERS_DECLARE_ISSUE_BASE__( namespace_name, class_name, ers::Issue, ERS_EMPTY message_, ERS_EMPTY, attributes ) \ __ERS_DEFINE_ISSUE_BASE__( inline, namespace_name, class_name, ers::Issue, ERS_EMPTY message_, ERS_EMPTY, attributes ) \ - static inline TraceStreamer& operator<<(TraceStreamer& x, const namespace_name::class_name &r) \ + namespace namespace_name { \ + static inline TraceStreamer& operator<<(TraceStreamer& x, const class_name &r) \ {if (x.do_m) {\ x.line_=r.context().line_number(); x.msg_append( r.message().c_str() );\ /* MAY NEED TO APPEND CHAINED ISSUE??? */ \ @@ -75,6 +78,7 @@ x.do_s = 0; \ } \ return x; \ - } + } \ + } #endif // LOGGING_INCLUDE_LOGGING_INTERNAL_MACRO_HPP_ diff --git a/test/apps/basic_functionality_example.cxx b/test/apps/basic_functionality_example.cxx index 5677612..e9c889f 100644 --- a/test/apps/basic_functionality_example.cxx +++ b/test/apps/basic_functionality_example.cxx @@ -120,7 +120,7 @@ int main(/*int argc, char *argv[]*/) TLOG_DEBUG(64) << "debug lvl 64"; TLOG() << "\ntshow follows:\n\n"; - system( "TRACE_TIME_FMT=\"%Y-%b-%d %H:%M:%S,%%03d\" TRACE_SHOW=\"%H%x%N %T %e %l %L %m\" trace_cntl show | trace_delta -ct 1 -d 1" ); + system( "TRACE_TIME_FMT='%Y-%b-%d %H:%M:%S,%%03d' TRACE_SHOW='%H%x%N %T %e %l %8L %m' trace_cntl show | trace_delta -ct 1 -d 1" ); TLOG() << "\nOne could try the same with DUNEDAQ_ERS_VERBOSITY_LEVEL=2 or 3\n"; @@ -138,7 +138,7 @@ int main(/*int argc, char *argv[]*/) threads[uu].join(); TLOG() << "\ntshow follows:\n\n"; - system( "TRACE_SHOW=\"%H%x%N %T %P %i %C %e %L %R %m\" trace_cntl show -c 25 | trace_delta -ct 1 -d 1" ); + system( "TRACE_SHOW='%H%x%N %T %P %i %C %e %3L %R %m' trace_cntl show -c 25 | trace_delta -ct 1 -d 1" ); throw( appframework::MyExit(ERS_HERE) ); return (0); diff --git a/test/apps/log_progress_update.cxx b/test/apps/log_progress_update.cxx index aff3d16..6332cc1 100644 --- a/test/apps/log_progress_update.cxx +++ b/test/apps/log_progress_update.cxx @@ -1,7 +1,7 @@ #ifndef DUNEDAQ_PACKAGE_NAME // this could/may be (tbd) set by the build system # define DUNEDAQ_PACKAGE_NAME "Logging_" // becomes an ERS Qualifier #endif -#include +#include // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG< #include @@ -39,12 +39,24 @@ int main(/*int argc, char *argv[]*/) setenv("DUNEDAQ_APPLICATION_NAME","LOGGING_PROGRESS_APP",0); dunedaq::logging::Logging::setup(); // not strictly needed -- checks/establishes a default env. - std::atomic m_generated_tot{ 3 }; + std::atomic m_generated_tot{ 7 }; std::vector theList{1,2,3}; std::ostringstream oss_prog; + TLOG() << "start"; oss_prog << "Generated list #" << m_generated_tot.load() << " with contents " << theList << " and size " << theList.size() << ". "; - TLOG_DEBUG() << (ProgressUpdate(ERS_HERE, "someName", oss_prog.str())); + std::cout << typeid(ProgressUpdate).name() << "\n\n"; + + TLOG() << static_cast(ProgressUpdate(ERS_HERE, "someName1", oss_prog.str())); + +#if 1 + TLOG_DEBUG() << ProgressUpdate(ERS_HERE, "someName2", oss_prog.str()); + std::cout << ProgressUpdate(ERS_HERE, "someName3", oss_prog.str()) << '\n'; + + TLOG_DEBUG() << ProgressUpdate(ERS_HERE, "someName4", oss_prog.str()); + TLOG_DEBUG() << ProgressUpdate(ERS_HERE, "someName5", oss_prog.str()); +#endif + return 0; } diff --git a/test/apps/multithreaded_warning_log.cxx b/test/apps/multithreaded_warning_log.cxx index ad86250..a205625 100644 --- a/test/apps/multithreaded_warning_log.cxx +++ b/test/apps/multithreaded_warning_log.cxx @@ -21,7 +21,7 @@ example: %s #include // rand_r, RAND_MAX #include #include -#define JUST_ERS 1 +#define JUST_ERS 0 #if JUST_ERS # include #else