Add better trace peudo-loglevel support
authorPerttu Ahola <celeron55@gmail.com>
Sun, 20 May 2012 15:30:30 +0000 (18:30 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 20 May 2012 15:30:30 +0000 (18:30 +0300)
src/log.cpp
src/log.h
src/main.cpp

index 5798310962016ce7b42c46018030bfc8e59908ca..a963f4c27832b1179cf0842157ada44f29ef1f7c 100644 (file)
@@ -159,4 +159,5 @@ std::ostream actionstream(&actionbuf);
 std::ostream infostream(&infobuf);
 std::ostream verbosestream(&verbosebuf);
 
+bool log_trace_level_enabled = false;
 
index afbce57e92f541863cc3bd5ad20a756d2facd301..46af3f33f943035429061156f2406211c6e414cd 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -69,5 +69,10 @@ extern std::ostream actionstream;
 extern std::ostream infostream;
 extern std::ostream verbosestream;
 
+extern bool log_trace_level_enabled;
+
+#define TRACESTREAM(x){ if(log_trace_level_enabled) verbosestream x; }
+#define TRACEDO(x){ if(log_trace_level_enabled){ x ;} }
+
 #endif
 
index a990032dfdec83c46eafad7d14d2998298d720b4..b133722c35af700efff9e152da214df7e75a0f1d 100644 (file)
@@ -854,8 +854,9 @@ int main(int argc, char *argv[])
        // If trace is enabled, enable logging of certain things
        if(cmd_args.getFlag("trace")){
                dstream<<"Enabling trace level debug output"<<std::endl;
-               dout_con_ptr = &verbosestream;
-               socket_enable_debug_output = true;
+               log_trace_level_enabled = true;
+               dout_con_ptr = &verbosestream; // this is somewhat old crap
+               socket_enable_debug_output = true; // socket doesn't use log.h
        }
        // In certain cases, output info level on stderr
        if(cmd_args.getFlag("info") || cmd_args.getFlag("verbose") ||