r3309 - in trunk/libmutil: include/libmutil source

erik at minisip.org erik at minisip.org
Wed Jun 13 19:28:07 CEST 2007


Author: erik
Date: 2007-06-13 19:28:07 +0200 (Wed, 13 Jun 2007)
New Revision: 3309

Modified:
   trunk/libmutil/include/libmutil/dbg.h
   trunk/libmutil/source/dbg.cxx
Log:

 * Make it possible to turn on/off adding the name of the stream to 
   the beginning of all lines.

   Make the default to not do it (makes sence to have the default
   behavour to match that of cerr/cout).




Modified: trunk/libmutil/include/libmutil/dbg.h
===================================================================
--- trunk/libmutil/include/libmutil/dbg.h	2007-06-13 15:20:05 UTC (rev 3308)
+++ trunk/libmutil/include/libmutil/dbg.h	2007-06-13 17:28:07 UTC (rev 3309)
@@ -97,6 +97,20 @@
 	bool getEnabled();
 	void setExternalHandler(DbgHandler * dbgHandler);
 
+	/**
+	 * Set to true to make the output stream prefix all lines with
+	 * the name of the stream.
+	 * Example if true
+	 *     mout << "hello" << endl;
+	 *   results in
+	 *     [mout] hello
+	 * Example if false
+	 *     mout << "hello" << endl;
+	 *   results in
+	 *     hello
+	 */
+	void setPrintStreamName(bool b);
+
 	Dbg& operator()(std::string oClass);
 	void include(std::string);
 	void exclude(std::string);
@@ -116,6 +130,7 @@
 	std::set< std::string > excludeSet;
 	bool filterBlocking;
 	Mutex *setLock;
+	bool printName;
 };
 
 extern LIBMUTIL_API Dbg mout;

Modified: trunk/libmutil/source/dbg.cxx
===================================================================
--- trunk/libmutil/source/dbg.cxx	2007-06-13 15:20:05 UTC (rev 3308)
+++ trunk/libmutil/source/dbg.cxx	2007-06-13 17:28:07 UTC (rev 3309)
@@ -52,7 +52,8 @@
 		debugHandler(NULL),
 		defaultInclude(true),
 		filterBlocking(false),
-		setLock(NULL)
+		setLock(NULL),
+		printName(false)
 
 {
 	setLock = new Mutex;
@@ -83,11 +84,13 @@
 
 	if (doFlush){
 		std::string prefix;
-		if (curClass.size()>0)
-			prefix = "[" + curClass + "] ";
-		else
-			prefix = "[" + name + "] ";
-			
+		if (printName){
+			if (curClass.size()>0)
+				prefix = "[" + curClass + "] ";
+			else
+				prefix = "[" + name + "] ";
+		}
+
 		if (debugHandler!=NULL){
 			debugHandler->displayMessage(prefix+str,0);
 			str="";



More information about the Minisip-devel mailing list