More clean-ups and cool template stuff
[invirt/third/libt4.git] / threaded_log.h
similarity index 88%
rename from tprintf.h
rename to threaded_log.h
index 41539fe..6918220 100644 (file)
--- a/tprintf.h
@@ -1,5 +1,5 @@
-#ifndef tprintf_h
-#define tprintf_h
+#ifndef threaded_log_h
+#define threaded_log_h
 
 #include <iomanip>
 #include <iostream>
@@ -12,7 +12,7 @@ extern std::map<std::thread::id, int> thread_name_map;
 extern int next_thread_num;
 extern std::map<void *, int> instance_name_map;
 extern int next_instance_num;
-extern char tprintf_thread_prefix;
+extern char log_thread_prefix;
 
 template <class A>
 struct iterator_pair : public std::pair<A, A> {
@@ -51,7 +51,7 @@ std::ostream & operator<<(std::ostream &o, const iterator_pair<A> &d) {
         _tid_ = thread_name_map[_thread_] = ++next_thread_num; \
     auto _utime_ = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count() % 1000000000; \
     std::cerr << std::setfill('0') << std::dec << std::left << std::setw(9) << _utime_ << " "; \
-    std::cerr << tprintf_thread_prefix << std::left << std::setw(2) << _tid_; \
+    std::cerr << std::setfill(' ') << log_thread_prefix << std::left << std::setw(2) << _tid_; \
     std::cerr << " " << std::setw(20) << __FILE__ << " " << std::setw(18) << __func__; \
 }
 #define LOG_THIS_POINTER { \
@@ -98,13 +98,4 @@ std::ostream & operator<<(std::ostream &o, const iterator_pair<A> &d) {
     LOG_SUFFIX; \
 }
 
-#define tprintf(...) { \
-    char *buf = nullptr; \
-    int len = asprintf(&buf, __VA_ARGS__); \
-    if (buf[len-1]=='\n') \
-        buf[len-1] = '\0'; \
-    LOG_NONMEMBER(buf); \
-    free(buf); \
-}
-
 #endif