2 #include "tbb/concurrent_unordered_map.h" 10 banner(
char const prefix)
12 std::ostringstream oss;
13 oss << std::string(5, prefix) <<
"> " << std::setw(6) <<
std::right 14 << std::this_thread::get_id() <<
std::left <<
" ";
22 return std::string(4,
' ');
24 std::ostringstream oss;
25 oss <<
"[" << std::setw(2) <<
std::right << std::setfill(
'0') <<
id 26 << std::setfill(
' ') << std::left <<
"]";
31 trimmed(std::string
const& fcn_name, std::string
const& pretty_fcn_name)
35 auto const begin_fcn_name = pretty_fcn_name.rfind(fcn_name);
36 auto const begin_qualified_fcn_name =
37 pretty_fcn_name.find_last_of(
' ', begin_fcn_name);
39 begin_qualified_fcn_name > begin_fcn_name ? 0 : begin_qualified_fcn_name;
41 if (
auto const stripped_begin = pretty_fcn_name.find(
"art::",
begin);
42 stripped_begin != std::string::npos) {
43 begin = stripped_begin + 5;
45 auto const substr_length = begin_fcn_name -
begin;
46 return pretty_fcn_name.substr(begin, substr_length) + fcn_name;
49 tbb::concurrent_unordered_map<art::ScheduleID, unsigned> indents;
54 auto it = indents.insert(std::make_pair(sid, 0)).first;
55 if (step ==
"Begin") {
56 auto const printed = it->second;
58 return std::string(printed,
' ');
59 }
else if (step ==
"End") {
60 auto const printed = --it->second;
61 return std::string(printed,
' ');
63 return std::string(it->second,
' ');
71 cvalue_ = getenv(
"ART_DEBUG_TASKS");
79 std::string
const& fcn_name,
80 std::string
const& pretty_fcn_name,
82 std::string
const& step)
84 buffer_ << banner(banner_prefix) << schedule_to_str(sid) <<
" " 85 << indent_for(step, sid) << std::left << std::setw(6) << step
86 << trimmed(fcn_name, pretty_fcn_name);
91 auto const user_message = usr_msg_.str();
92 if (not
empty(user_message)) {
93 buffer_ <<
" - " << user_message;
96 std::cerr << buffer_.str();
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
MessageAccumulator(char const banner_prefix, std::string const &fcn_name, std::string const &pretty_fcn_name, ScheduleID schedule_id=ScheduleID{}, std::string const &step=std::string(6, ' '))
DebugTasksValue debugTasks
std::atomic< int > value_
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
std::atomic< char const * > cvalue_
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.