Clean-ups and fixes to compile with more warnings enabled and with g++.
[invirt/third/libt4.git] / threaded_log.h
index ebb2222..bccd813 100644 (file)
@@ -10,27 +10,8 @@ extern map<void *, int> instance_name_map;
 extern int next_instance_num;
 extern char log_thread_prefix;
 
-namespace std {
-    // This... is an awful hack.  But sticking this in std:: makes it possible for
-    // ostream_iterator to use it.
-    template <class A, class B>
-    ostream & operator<<(ostream &o, const pair<A,B> &d) {
-        return o << "<" << d.first << "," << d.second << ">";
-    }
-}
-
-template <class A>
-typename enable_if<is_iterable<A>::value && !is_same<A,string>::value, ostream>::type &
-operator<<(ostream &o, const A &a) {
-    o << "[";
-    auto oit = ostream_iterator<typename A::value_type>(o, ", ");
-    copy(a.begin(), a.end(), oit);
-    o << "]";
-    return o;
-}
-
 #define LOG_PREFIX { \
-    auto _thread_ = std::this_thread::get_id(); \
+    auto _thread_ = this_thread::get_id(); \
     int _tid_ = thread_name_map[_thread_]; \
     if (_tid_==0) \
         _tid_ = thread_name_map[_thread_] = ++next_thread_num; \
@@ -43,7 +24,7 @@ operator<<(ostream &o, const A &a) {
     int _self_ = instance_name_map[this]; \
     if (_self_==0) \
         _self_ = instance_name_map[this] = ++next_instance_num; \
-    cerr << "#" << setw(2) << _self_; \
+    cerr << "#" << left << setw(2) << _self_ << " "; \
 }
 
 #define LOG_NONMEMBER(_x_) { \
@@ -58,4 +39,8 @@ operator<<(ostream &o, const A &a) {
     cerr << _x_ << endl; \
 }
 
+extern int DEBUG_LEVEL;
+
+#define IF_LEVEL(level) if(DEBUG_LEVEL >= abs(level))
+
 #endif