CVS update: samba/source/param

Peter Samuelson peter at cadcamlab.org
Wed May 31 22:37:32 EST 2000


[lckl]
> it's just that those debug timestamps drive me UP THE WALL

Here, put this in TNG.  Then use the parameters

  debug timestamp = True
  debug timestamp throttle = 180

and presto, you have timestamps but always at least 3 minutes apart.
Default is 0 meaning no throttling.  (For TNG you may want to change
the default.)

I'll let you, Tridge and Jeremy duke it out over whether this sort of
thing should go in HEAD, and if so, what the default should be.

Peter

diff -urNk.bak samba-tng/source/lib/debug.c.bak samba-tng/source/lib/debug.c
--- samba-tng/source/lib/debug.c.bak	Mon May  1 23:49:52 2000
+++ samba-tng/source/lib/debug.c	Wed May 31 07:25:15 2000
@@ -435,6 +435,38 @@
 
 
 /* ************************************************************************** **
+ * Indicate whether a debug header should be printed
+ *
+ *  Input:  header - whether or not we are planning to actually print one
+ *  Output: T/F (side effect: resets timeout period for "timestamp throttle"
+ *
+ * ************************************************************************** **
+ */
+static BOOL timestamp_ok(BOOL header)
+{
+	static time_t last_printed = 0;
+	time_t now;
+
+	/* Pay attention to the order here... */
+	if( !timestamp_log || stdout_logging )
+		return False;
+	if( !lp_loaded() )
+		return True;
+	if( !lp_timestamp_logs() )
+		return False;
+	if( !header )
+		return True;
+
+	now = time(NULL);
+	if( now - last_printed >= (time_t)lp_timestamp_throttle() )
+	{
+		last_printed = now;
+		return True;
+	}
+	return False;
+}
+
+/* ************************************************************************** **
  * Print the buffer content via Debug1(), then reset the buffer.
  *
  *  Input:  none
@@ -469,13 +501,11 @@
 static void format_debug_text( char *msg )
   {
   size_t i;
-  BOOL timestamp = (timestamp_log && !stdout_logging && (lp_timestamp_logs() || 
-					!(lp_loaded())));
 
   for( i = 0; msg[i]; i++ )
     {
     /* Indent two spaces at each new line. */
-    if(timestamp && 0 == format_pos)
+    if(timestamp_ok(False) && 0 == format_pos)
       {
       format_bufr[0] = format_bufr[1] = ' ';
       format_pos = 2;
@@ -564,14 +594,7 @@
   syslog_level = level;
 #endif
 
-  /* Don't print a header if we're logging to stdout. */
-  if( stdout_logging )
-    return( True );
-
-  /* Print the header if timestamps are turned on.  If parameters are
-   * not yet loaded, then default to timestamps on.
-   */
-  if( timestamp_log && (lp_timestamp_logs() || !(lp_loaded()) ))
+  if(timestamp_ok(True))
     {
     char header_str[200];
 
diff -urNk.bak samba-tng/source/param/loadparm.c.bak samba-tng/source/param/loadparm.c
--- samba-tng/source/param/loadparm.c.bak	Wed May 31 05:58:45 2000
+++ samba-tng/source/param/loadparm.c	Wed May 31 06:13:34 2000
@@ -208,6 +208,7 @@
 	int min_passwd_length;
 	int oplock_break_wait_time;
 	int winbind_cache_time;
+	int timestamp_throttle;
 #if defined(WITH_LDAP) || defined(WITH_NT5LDAP)
 	int ldap_port;
 	int ldap_protocol_version;
@@ -832,6 +833,8 @@
 	 NULL, 0},
 	{"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL,
 	 NULL, 0},
+	{"debug timestamp throttle", P_INTEGER, P_GLOBAL, &Globals.timestamp_throttle,
+	 NULL, NULL, 0},
 	{"debug hires timestamp", P_BOOL, P_GLOBAL,
 	 &Globals.bDebugHiresTimestamp, NULL, NULL, 0},
 	{"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, 0},
@@ -1383,6 +1386,7 @@
 	Globals.syslog = 1;
 	Globals.bSyslogOnly = False;
 	Globals.bTimestampLogs = False;
+	Globals.timestamp_throttle = 0;
 	Globals.bDebugHiresTimestamp = False;
 	Globals.bDebugPid = False;
 	Globals.bDebugUid = False;
@@ -1852,6 +1856,7 @@
 FN_GLOBAL_INTEGER(lp_map_to_guest, &Globals.map_to_guest)
 FN_GLOBAL_INTEGER(lp_min_passwd_length, &Globals.min_passwd_length)
 FN_GLOBAL_INTEGER(lp_oplock_break_wait_time, &Globals.oplock_break_wait_time)
+FN_GLOBAL_INTEGER(lp_timestamp_throttle, &Globals.timestamp_throttle)
 #if defined(WITH_LDAP) || defined(WITH_NT5LDAP)
 FN_GLOBAL_INTEGER(lp_ldap_port, &Globals.ldap_port)
 FN_GLOBAL_INTEGER(lp_ldap_protocol_version, &Globals.ldap_protocol_version)


More information about the samba-cvs mailing list