[Spread-cvs] commit: r408 - in trunk: daemon docs

jonathan at spread.org jonathan at spread.org
Thu Jan 22 18:30:20 EST 2009


Author: jonathan
Date: 2009-01-22 18:30:20 -0500 (Thu, 22 Jan 2009)
New Revision: 408

Modified:
   trunk/daemon/Changelog
   trunk/daemon/alarm.c
   trunk/daemon/alarm.h
   trunk/daemon/config_gram.l
   trunk/daemon/config_parse.y
   trunk/docs/sample.spread.conf
Log:
Add option to Alarm subsytem to print out microsecond resolution timestamps along with the standard 
timestamps in Alarm() logged events. These timestamps are enabled through the spread.conf file.

New functions added are Alarm_enable_precise_timestamp(), Alarm_disable_precise_timestamp(). 



Modified: trunk/daemon/Changelog
===================================================================
--- trunk/daemon/Changelog	2009-01-11 20:56:46 UTC (rev 407)
+++ trunk/daemon/Changelog	2009-01-22 23:30:20 UTC (rev 408)
@@ -1,3 +1,11 @@
+Thu Jan 22 18:23:00 2009  Jonathan Stanton  <jonathan at spreadconcepts.com>
+
+	* alarm.c (Alarm, Alarmp, Alarm_enable_precise_timestamp): Add 
+	option to Spread daemon to print a very precise (microsecond) 
+	timestamp in the Alarm log records. The normal log records only
+	print a second resolution timestamp. To enable this option add
+	the string "EventPreciseTimeStamp" to the spread.conf file. 
+
 Mon Nov 17 20:12:20 2008  Jonathan Stanton  <jonathan at spreadconcepts.com>
 
 	* data_link.c (DL_send): Zero the msg struct before filling it in. 

Modified: trunk/daemon/alarm.c
===================================================================
--- trunk/daemon/alarm.c	2009-01-11 20:56:46 UTC (rev 407)
+++ trunk/daemon/alarm.c	2009-01-22 23:30:20 UTC (rev 408)
@@ -53,11 +53,15 @@
 
 #include "alarm.h"
 
+#include "sp_events.h"
+
 static int32	Alarm_type_mask = PRINT | EXIT  ;
 static  int16   Alarm_cur_priority = SPLOG_DEBUG ;
 
 static char     *Alarm_timestamp_format = NULL;
 
+static int      Alarm_precise_timestamp = FALSE;
+
 static const char *DEFAULT_TIMESTAMP_FORMAT="[%a %d %b %Y %H:%M:%S]";
 
 static int      AlarmInteractiveProgram = FALSE;
@@ -89,6 +93,14 @@
 				  Alarm_timestamp_format, tm_now);
 		timestamp[length] = ' ';
 		fwrite(timestamp, length+1, sizeof(char), stdout);
+                if ( Alarm_precise_timestamp )
+                {
+                    sp_time precise_now;
+                    precise_now = E_get_time();
+                    length = sprintf (timestamp, " (%lu us): ", precise_now.usec);
+                    timestamp[length] = ' ';
+                    fwrite(timestamp, length+1, sizeof(char), stdout);
+                }
             }
 
 	    va_start(ap,message);
@@ -125,6 +137,14 @@
 				  Alarm_timestamp_format, tm_now);
 		timestamp[length] = ' ';
 		fwrite(timestamp, length+1, sizeof(char), stdout);
+                if ( Alarm_precise_timestamp )
+                {
+                    sp_time precise_now;
+                    precise_now = E_get_time();
+                    length = sprintf (timestamp, " (%lu us): ", precise_now.usec);
+                    timestamp[length] = ' ';
+                    fwrite(timestamp, length+1, sizeof(char), stdout);
+                }
             }
 
 	    va_start(ap,message);
@@ -162,6 +182,14 @@
 				  Alarm_timestamp_format, tm_now);
 		timestamp[length] = ' ';
 		fwrite(timestamp, length+1, sizeof(char), stdout);
+                if ( Alarm_precise_timestamp )
+                {
+                    sp_time precise_now;
+                    precise_now = E_get_time();
+                    length = sprintf (timestamp, " (%lu us): ", precise_now.usec);
+                    timestamp[length] = ' ';
+                    fwrite(timestamp, length+1, sizeof(char), stdout);
+                }
             }
 	    printf(message, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7, ptr8, ptr9, ptr10, ptr11, ptr12, ptr13, ptr14, ptr15, ptr16, ptr17, ptr18, ptr19, ptr20 );
 
@@ -185,6 +213,16 @@
         return(AlarmInteractiveProgram);
 }
 
+void Alarm_enable_precise_timestamp(void) 
+{
+        Alarm_precise_timestamp = TRUE;
+}
+
+void Alarm_disable_precise_timestamp(void) 
+{
+        Alarm_precise_timestamp = FALSE;
+}
+
 void Alarm_set_output(char *filename) {
         FILE *newfile;
         newfile = freopen(filename, "a", stdout);

Modified: trunk/daemon/alarm.h
===================================================================
--- trunk/daemon/alarm.h	2009-01-11 20:56:46 UTC (rev 407)
+++ trunk/daemon/alarm.h	2009-01-22 23:30:20 UTC (rev 408)
@@ -100,6 +100,9 @@
 void Alarm_enable_timestamp(char *format);
 void Alarm_disable_timestamp(void);
 
+void Alarm_enable_precise_timestamp(void); 
+void Alarm_disable_precise_timestamp(void);
+
 void Alarm_set_types(int32 mask);
 void Alarm_clear_types(int32 mask);
 int32 Alarm_get_types(void);

Modified: trunk/daemon/config_gram.l
===================================================================
--- trunk/daemon/config_gram.l	2009-01-11 20:56:46 UTC (rev 407)
+++ trunk/daemon/config_gram.l	2009-01-22 23:30:20 UTC (rev 408)
@@ -80,6 +80,7 @@
 Spread_Segment                  { return SEGMENT; }
 EventLogFile                    { return EVENTLOGFILE; }
 EventTimeStamp                  { return EVENTTIMESTAMP; }
+EventPreciseTimeStamp           { return EVENTPRECISETIMESTAMP; }
 EventPriority                   { return EVENTPRIORITY; }
 DebugFlags                      { return DEBUGFLAGS; }
 DangerousMonitor                { return DANGEROUSMONITOR; }

Modified: trunk/daemon/config_parse.y
===================================================================
--- trunk/daemon/config_parse.y	2009-01-11 20:56:46 UTC (rev 407)
+++ trunk/daemon/config_parse.y	2009-01-22 23:30:20 UTC (rev 408)
@@ -312,7 +312,7 @@
 
 %}
 %start Config
-%token SEGMENT EVENTLOGFILE EVENTTIMESTAMP EVENTPRIORITY IPADDR NUMBER COLON
+%token SEGMENT EVENTLOGFILE EVENTTIMESTAMP EVENTPRECISETIMESTAMP EVENTPRIORITY IPADDR NUMBER COLON
 %token PDEBUG PINFO PWARNING PERROR PCRITICAL PFATAL
 %token OPENBRACE CLOSEBRACE EQUALS STRING
 %token DEBUGFLAGS BANG
@@ -414,6 +414,12 @@
 			    Alarm_enable_timestamp(NULL);
                           }
 			}
+		|	EVENTPRECISETIMESTAMP
+			{
+			  if (! Alarm_get_interactive() ) {
+                            Alarm_enable_precise_timestamp();
+                          }
+			}
 		|	DANGEROUSMONITOR EQUALS SP_BOOL
 			{
 			  if (! Alarm_get_interactive() ) {

Modified: trunk/docs/sample.spread.conf
===================================================================
--- trunk/docs/sample.spread.conf	2009-01-11 20:56:46 UTC (rev 407)
+++ trunk/docs/sample.spread.conf	2009-01-22 23:30:20 UTC (rev 408)
@@ -76,6 +76,14 @@
 # or
 #EventTimeStamp = "[%a %d %b %Y %H:%M:%S]"
 
+#Set whether to add a precise (microsecond) resolution timestamp to all logged
+# events or not. This option requires that EventTimeStamp is also enabled. 
+# If the option is commented out then the microsecond timestamp is not added
+# If the option is uncommented then a microsecond time will print in addition
+#  to the H:M:S resolution timestamp provided by EventTimeStamp. 
+
+#EventPreciseTimeStamp
+
 # Set to initialize daemon sequence numbers to a 'large' number for testing
 # this is purely a debugging capability and should never be enabled on
 # production systems (note one side effect of enabling this is that 




More information about the Spread-cvs mailing list