[openib-general] OpenSM Log Message Format

Eitan Zahavi eitan at mellanox.co.il
Wed Jan 12 07:21:47 PST 2005


Hi Hal,

I have incorporated your patch into the next next release code.
If it is urgent you can put it directly into gen2 too.

EZ

Eitan Zahavi
Design Technology Director
Mellanox Technologies LTD
Tel:+972-4-9097208
Fax:+972-4-9593245
P.O. Box 586 Yokneam 20692 ISRAEL


-----Original Message-----
From: Hal Rosenstock [mailto:halr at voltaire.com] 
Sent: Wednesday, January 12, 2005 4:05 PM
To: openib-general at openib.org
Subject: [openib-general] OpenSM Log Message Format

Hi,

Should date/time format be used rather than timeval when OSM logs
messages ? That would make the messages more like the other daemons.
Here's a proposed patch to do this.

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

-- Hal
Index: osm_log.c
===================================================================
--- osm_log.c	(revision 1519)
+++ osm_log.c	(working copy)
@@ -96,6 +96,23 @@
 #include <unistd.h>
 #endif
 
+#ifndef WIN32
+static char *month_str[] = {
+  "Jan",
+  "Feb",
+  "Mar",
+  "Apr",
+  "May",
+  "Jun",
+  "Jul",
+  "Aug",
+  "Sep",
+  "Oct",
+  "Nov",
+  "Dec"
+};
+#endif
+
 void
 osm_log(
   IN osm_log_t* const p_log,
@@ -111,8 +128,8 @@
   uint32_t pid = GetCurrentThreadId();
 #else
   pid_t pid;
-  struct timeval tv;
-  struct timezone tz;
+  time_t tim;
+  struct tm result;
 #endif /*  WIN32 */
 
   /* If this is a call to syslog - always print it */
@@ -152,9 +169,12 @@
       
 #else
       pid = pthread_self();
-      gettimeofday( &tv, &tz );
-      ret = fprintf( p_log->out_port, "[%09ld:%09ld][%04X] -> %s",
-                     tv.tv_sec, (long)tv.tv_usec,
+      tim = time(NULL);
+      localtime_r(&tim, &result);
+      ret = fprintf( p_log->out_port, "%s %02d %02d:%02d:%02d [%04X] ->
%s",
+                    (result.tm_mon < 12 ? month_str[result.tm_mon] :
"???"),
+                     result.tm_mday, result.tm_hour,
+                     result.tm_min, result.tm_sec,
                      pid, buffer);
 #endif /*  WIN32 */
       



_______________________________________________
openib-general mailing list
openib-general at openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit
http://openib.org/mailman/listinfo/openib-general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20050112/de70e0d0/attachment.html>


More information about the general mailing list