#include "threaded_log.h"
-static mutex log_mutex;
-static map<thread::id, int> thread_name_map;
+static std::mutex log_mutex;
+static std::map<thread::id, int> thread_name_map;
static int next_thread_num = 0;
-static map<const void *, int> instance_name_map;
+static std::map<const void *, int> instance_name_map;
static int next_instance_num = 0;
int DEBUG_LEVEL = 0;
+using namespace std::chrono;
+
locked_ostream && _log_prefix(locked_ostream && f, const string & file, const string & func) {
- auto thread = this_thread::get_id();
+ auto thread = std::this_thread::get_id();
int tid = thread_name_map[thread];
if (tid==0)
tid = thread_name_map[thread] = ++next_thread_num;
- auto utime = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count() % 1000000000;
+ auto utime = duration_cast<microseconds>(
+ system_clock::now().time_since_epoch()).count() % 1000000000;
f << std::setfill('0') << std::dec << std::left << std::setw(9) << utime << " ";
f << std::setfill(' ') << log_thread_prefix << std::left << std::setw(2) << tid;
f << " " << std::setw(20) << file << " " << std::setw(18) << func;