21#ifndef LIBSEMIGROUPS_DETAIL_REPORT_HPP_
22#define LIBSEMIGROUPS_DETAIL_REPORT_HPP_
33#include "formatters.hpp"
41 t_id this_threads_id();
42 t_id thread_id(std::thread::id);
43 void reset_thread_ids();
45 bool is_report_suppressed_for(std::string_view);
57 TickerImpl* _ticker_impl;
62 template <
typename Func,
typename Time = std::chrono::seconds>
63 explicit Ticker(Func&& func, Time time = std::chrono::seconds(1));
66 Ticker(Ticker
const&) =
delete;
67 Ticker(Ticker&&) =
delete;
68 Ticker& operator=(Ticker
const&) =
delete;
69 Ticker& operator=(Ticker&&) =
delete;
84 using Row = std::array<std::string, C + 1>;
86 std::array<size_t, C + 1> _col_widths;
87 std::vector<Row> _rows;
90 ReportCell() : _col_widths(), _rows() {
94 ReportCell(ReportCell
const&) =
delete;
95 ReportCell(ReportCell&&) =
delete;
96 ReportCell& operator=(ReportCell
const&) =
delete;
97 ReportCell& operator=(ReportCell&&) =
delete;
104 ReportCell& min_width(
size_t val) {
105 _col_widths.fill(val);
110 ReportCell& min_width(
size_t col,
size_t val) {
111 LIBSEMIGROUPS_ASSERT(col < C);
112 _col_widths[col + 1] = val;
117 template <
typename... Args>
118 void operator()(std::string_view fmt_str, Args&&... args);
122 template <
typename Func,
typename... Args>
123 void operator()(Func&& f,
char const* fmt_str, Args&&... args) {
124 operator()(fmt_str, f(args)...);
128 size_t line_width()
const;
138 template <typename... Args>
140 std::string prefix = fmt::format(
"#{}: ", detail::this_threads_id());
145 template <
typename... Args>
156 template <
typename... Args>
159 std::string_view prefix(sv);
160 auto pos = prefix.find(
":");
161 if (pos != std::string::npos) {
162 prefix.remove_suffix(prefix.size() - prefix.find(
":"));
163 if (detail::is_report_suppressed_for((prefix))) {
174 libsemigroups::detail::Timer
const& tmr) {
197 class SuppressReportFor {
198 std::string_view _prefix;
201 explicit SuppressReportFor(std::string_view);
202 ~SuppressReportFor();
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
bool reporting_enabled() noexcept
No doc.
void report_default(std::string_view sv, Args &&... args)
No doc.
Definition report.hpp:157
static void report_elapsed_time(std::string_view prefix, libsemigroups::detail::Timer const &tmr)
No doc.
Definition report.hpp:173
std::string fmt_default(std::string_view sv, Args &&... args)
No doc.
Definition report.hpp:139
void report_no_prefix(std::string_view sv, Args &&... args)
No doc.
Definition report.hpp:146
ReportGuard(bool val=true)
Constructs a ReportGuard with reporting enabled by default.