Line data Source code
1 : #ifndef DUNEDAQ_PACKAGE_NAME // this could/may be (tbd) set by the build system
2 : # define DUNEDAQ_PACKAGE_NAME "Logging_" // becomes an ERS Qualifier
3 : #endif
4 : #include <logging/Logging.hpp> // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
5 : #include <ers/Issue.hpp>
6 : #include <vector>
7 :
8 0 : ERS_DECLARE_ISSUE(appfwk, ///< Namespace
9 : GeneralDAQModuleIssue, ///< Issue class name
10 : " DAQModule: " << name, ///< Message
11 : ((std::string)name) ///< Message parameters
12 : )
13 :
14 0 : ERS_DECLARE_ISSUE_BASE(logging,
15 : ProgressUpdate,
16 : appfwk::GeneralDAQModuleIssue,
17 : message,
18 : ((std::string)name),
19 : ((std::string)message))
20 :
21 : using namespace logging;
22 :
23 : std::ostream&
24 0 : operator<<(std::ostream& t, std::vector<int> ints)
25 : {
26 0 : t << "{";
27 0 : bool first = true;
28 0 : for (auto& i : ints) {
29 0 : if (!first)
30 0 : t << ", ";
31 0 : first = false;
32 0 : t << i;
33 : }
34 0 : return t << "}";
35 : }
36 :
37 0 : int main(/*int argc, char *argv[]*/)
38 : {
39 0 : dunedaq::logging::Logging::setup("test", "log_progress_update");
40 :
41 0 : std::atomic<uint64_t> m_generated_tot{ 7 };
42 0 : std::vector<int> theList{1,2,3};
43 0 : std::ostringstream oss_prog;
44 0 : TLOG() << "start";
45 0 : oss_prog << "Generated list #" << m_generated_tot.load() << " with contents " << theList
46 0 : << " and size " << theList.size() << ". ";
47 :
48 0 : std::cout << typeid(ProgressUpdate).name() << "\n\n";
49 :
50 0 : TLOG() << static_cast<logging::ProgressUpdate>(ProgressUpdate(ERS_HERE, "someName1", oss_prog.str()));
51 :
52 : #if 1
53 0 : TLOG_DEBUG() << ProgressUpdate(ERS_HERE, "someName2", oss_prog.str());
54 0 : std::cout << ProgressUpdate(ERS_HERE, "someName3", oss_prog.str()) << '\n';
55 :
56 0 : TLOG_DEBUG() << ProgressUpdate(ERS_HERE, "someName4", oss_prog.str());
57 0 : TLOG_DEBUG() << ProgressUpdate(ERS_HERE, "someName5", oss_prog.str());
58 : #endif
59 :
60 0 : return 0;
61 0 : }
|