new smb.conf parameter

Herb Lewis hlewis at panasas.com
Fri Mar 9 22:50:09 GMT 2007


I would like to propose adding a new smb.conf parameter
to allow a short timestamp header to be added to DEBUG
messages. Having debug timestamp set basically doubles
the number of lines in your log file but without it you
have no timestamps to correlate with other system events.

I was thinking of calling it timestamponly and default to
False. If it is set then the timestamp (all the stuff
between the [] which could include pid, etc.) is added
to the beginning of the debug message without a newline
so it comes out on the same line as the message.

Here is a proposed patch against 3.0.25. Does this look
useful to people or not?

-------------- next part --------------
Index: param/loadparm.c
===================================================================
--- param/loadparm.c	(revision 21775)
+++ param/loadparm.c	(working copy)
@@ -276,6 +276,7 @@
 	BOOL bPasswdChatDebug;
 	int iPasswdChatTimeout;
 	BOOL bTimestampLogs;
+	BOOL bTimestampOnly;
 	BOOL bNTSmbSupport;
 	BOOL bNTPipeSupport;
 	BOOL bNTStatusSupport;
@@ -953,6 +954,7 @@
 	{"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, FLAG_ADVANCED}, 
 	{"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED}, 
 	{"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED}, 
+	{"timestamponly", P_BOOL, P_GLOBAL, &Globals.bTimestampOnly, NULL, NULL, FLAG_ADVANCED}, 
 	{"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_ADVANCED}, 
 	{"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_ADVANCED}, 
 	{"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_ADVANCED}, 
@@ -1516,6 +1518,7 @@
 	Globals.syslog = 1;
 	Globals.bSyslogOnly = False;
 	Globals.bTimestampLogs = True;
+	Globals.bTimestampOnly = False;
 	string_set(&Globals.szLogLevel, "0");
 	Globals.bDebugHiresTimestamp = False;
 	Globals.bDebugPid = False;
@@ -1945,6 +1948,7 @@
 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
+FN_GLOBAL_BOOL(lp_timestamponly, &Globals.bTimestampOnly)
 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)
Index: lib/debug.c
===================================================================
--- lib/debug.c	(revision 21775)
+++ lib/debug.c	(working copy)
@@ -962,7 +962,7 @@
 	/* Print the header if timestamps are turned on.  If parameters are
 	 * not yet loaded, then default to timestamps on.
 	 */
-	if( lp_timestamp_logs() || !(lp_loaded()) ) {
+	if( lp_timestamp_logs() || lp_timestamponly() || !(lp_loaded()) ) {
 		char header_str[200];
 
 		header_str[0] = '\0';
@@ -980,9 +980,15 @@
 		}
   
 		/* Print it all out at once to prevent split syslog output. */
-		(void)Debug1( "[%s, %d%s] %s:%s(%d)\n",
+		if( lp_timestamponly() ) {
+		    (void)Debug1( "[%s, %d%s] ",
 			current_timestring(lp_debug_hires_timestamp()), level,
+			header_str);
+		} else {
+		    (void)Debug1( "[%s, %d%s] %s:%s(%d)\n",
+			current_timestring(lp_debug_hires_timestamp()), level,
 			header_str, file, func, line );
+		}
 	}
 
 	errno = old_errno;


More information about the samba-technical mailing list