3 #include "threaded_log.h"
5 using namespace std::chrono;
7 locked_ostream && _log_prefix(locked_ostream && f, const string & file, const string & func) {
8 auto thread = std::this_thread::get_id();
9 int tid = global->thread_name_map[thread];
11 tid = global->thread_name_map[thread] = ++global->next_thread_num;
12 auto utime = duration_cast<microseconds>(
13 system_clock::now().time_since_epoch()).count() % 1000000000;
14 f << std::setfill('0') << std::dec << std::left << std::setw(9) << utime << " ";
15 f << std::setfill(' ') << global->log_thread_prefix << std::left << std::setw(2) << tid;
16 f << " " << std::setw(20) << file << " " << std::setw(18) << func;
20 locked_ostream && _log_member(locked_ostream && f, const void *ptr) {
21 int id = global->instance_name_map[ptr];
23 id = global->instance_name_map[ptr] = ++global->next_instance_num;
24 f << "#" << std::left << std::setw(2) << id << " ";
28 int _log_debug_level() {
29 return global->DEBUG_LEVEL;
33 return lock(global->log_mutex);