X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/eb3d5c6416c0f0d1cad35e52af3231de7866fea8..26ade07ab0e62b98b452fbbd18edba0450035e35:/threaded_log.cc diff --git a/threaded_log.cc b/threaded_log.cc index b450f52..96728f6 100644 --- a/threaded_log.cc +++ b/threaded_log.cc @@ -1,10 +1,10 @@ #include "threaded_log.h" -mutex cerr_mutex; -map thread_name_map; -int next_thread_num = 0; -map instance_name_map; -int next_instance_num = 0; +static mutex log_mutex; +static map thread_name_map; +static int next_thread_num = 0; +static map instance_name_map; +static int next_instance_num = 0; int DEBUG_LEVEL = 0; locked_ostream && _log_prefix(locked_ostream && f, const string & file, const string & func) { @@ -13,16 +13,20 @@ locked_ostream && _log_prefix(locked_ostream && f, const string & file, const st if (tid==0) tid = thread_name_map[thread] = ++next_thread_num; auto utime = duration_cast(system_clock::now().time_since_epoch()).count() % 1000000000; - f << setfill('0') << dec << left << setw(9) << utime << " "; - f << setfill(' ') << log_thread_prefix << left << setw(2) << tid; - f << " " << setw(20) << file << " " << setw(18) << func; - return move(f); + 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; + return std::move(f); } locked_ostream && _log_member(locked_ostream && f, const void *ptr) { int id = instance_name_map[ptr]; if (id == 0) id = instance_name_map[ptr] = ++next_instance_num; - f << "#" << left << setw(2) << id << " "; - return move(f); + f << "#" << std::left << std::setw(2) << id << " "; + return std::move(f); +} + +lock _log_lock() { + return lock(log_mutex); }