SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
ProgressLogger.cpp
Go to the documentation of this file.
1
17#include <iomanip>
19
20namespace SourceXtractor {
21
22ProgressLogger::ProgressLogger(const std::chrono::steady_clock::duration& min_interval) :
23 m_logger{Elements::Logging::getLogger("Progress")}, m_min_interval{min_interval},
24 m_started{std::chrono::steady_clock::now()},
26}
27
30
31 if (now - m_last_logged > m_min_interval || m_done) {
32 auto elapsed = now - m_started;
33 m_last_logged = now;
34
35 for (auto entry : m_progress_info) {
36 // When there is no total, log an absolute count
37 if (entry.m_total <= 0) {
38 m_logger.info() << entry.m_label << ": " << entry.m_done;
39 }
40 // Otherwise, report progress
41 else {
42 float percent = (entry.m_done * 100.) / entry.m_total;
43 m_logger.info() << entry.m_label << ": " << entry.m_done << " / " << entry.m_total
44 << " (" << std::fixed << std::setprecision(2) << percent << "%)";
45 }
46 }
47
51 m_logger.info() << "Elapsed: " << std::setfill('0')
52 << std::setw(2) << h.count() << ':'
53 << std::setw(2) << m.count() << ':'
54 << std::setw(2) << s.count();
55 }
56}
57
62
63void ProgressLogger::handleMessage(const bool& done) {
64 m_done = done;
65 print();
66}
67
68} // end SourceXtractor
std::list< ProgressInfo > m_progress_info
std::chrono::steady_clock::time_point m_last_logged
ProgressLogger(const std::chrono::steady_clock::duration &min_interval)
void handleMessage(const std::list< ProgressInfo > &info) override
std::chrono::steady_clock::duration m_min_interval
std::chrono::steady_clock::time_point m_started
T duration_cast(T... args)
T fixed(T... args)
STL namespace.
T setfill(T... args)
T setprecision(T... args)
T setw(T... args)