1 #include "include/t4.h"
2 #include "include/types.h"
3 #include "include/debug.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 = (system_clock::now().time_since_epoch() / 1us) % 1000000000;
13 f << std::setfill('0') << std::dec << std::left << std::setw(9) << utime << " ";
14 f << std::setfill(' ') << global->log_thread_prefix << std::left << std::setw(2) << tid;
15 f << " " << std::setw(20) << file << " " << std::setw(18) << func;
19 locked_ostream && _log_member(locked_ostream && f, const void *ptr) {
20 int id = global->instance_name_map[ptr];
22 id = global->instance_name_map[ptr] = ++global->next_instance_num;
23 f << "#" << std::left << std::setw(2) << id << " ";
27 int _log_debug_level() {
28 return global->DEBUG_LEVEL;
32 return lock(global->log_mutex);
35 string hex_string(const string & s) {
38 bytes.push_back("0123456789abcdef"[(uint8_t)ch >> 4]);
39 bytes.push_back("0123456789abcdef"[(uint8_t)ch & 15]);