Skip to content

Commit

Permalink
add Eric's stream operator
Browse files Browse the repository at this point in the history
  • Loading branch information
bieryAtFnal committed Mar 25, 2024
1 parent d5f8bcc commit 874c80e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions test/apps/log_progress_update.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,48 @@
#endif
#include <logging/Logging.hpp>
#include <ers/Issue.hpp>
#include <vector>

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<int> 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<uint64_t> m_generated_tot{ 3 };
std::vector<int> 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;
}

0 comments on commit 874c80e

Please sign in to comment.