debug prints

Herb Lewis hlewis at panasas.com
Tue Aug 7 17:11:51 MDT 2012


There was some discussion a while back about always including the 
function name in the
debug header. I'd like to propose the following patch. It does 2 things. 
It adds printing
"func" value passed to the dbghdrclass function in all 3 cases - no 
timestamp, normal
timestamp and debug prefix timestamp. It also changes dbghdrclass to use 
dbgtext
instead of Debug1 so the whole line is printed at the same time. This 
prevents log.smbd
from having many garbled lines when there is heavy traffic.

Of course when this patch is applied we need to clean up all the DEBUG 
statements to
not print the (many times incorrect) function name.
-------------- next part --------------
--- samba-3.6.6/lib/util/debug.c	2012-06-24 10:21:16.000000000 -0700
+++ samba-3.6.6/lib/util/debug.c.new	2012-08-07 16:01:32.998782500 -0700
@@ -960,18 +960,20 @@
 		if( state.settings.debug_prefix_timestamp ) {
 			char *time_str = current_timestring(NULL,
 							    state.settings.debug_hires_timestamp);
-			(void)Debug1( "[%s, %2d%s] ",
+			(void)dbgtext( "[%s, %2d%s] %s: ",
 				      time_str,
-				      level, header_str);
+				      level, header_str, func);
 			talloc_free(time_str);
 		} else {
 			char *time_str = current_timestring(NULL,
 							    state.settings.debug_hires_timestamp);
-			(void)Debug1( "[%s, %2d%s] %s(%s)\n",
+			(void)dbgtext( "[%s, %2d%s] %s(%s)\n",
 				      time_str,
 				      level, header_str, location, func );
 			talloc_free(time_str);
 		}
+	} else {
+		(void)dbgtext( "%s[%d]: ", func, level);
 	}
 
 	errno = old_errno;


More information about the samba-technical mailing list