[ofa-general] [PATCH] opensm: osm_log - added the log message type to the message

Timothy A. Meier meier3 at llnl.gov
Thu Nov 8 16:35:08 PST 2007


Sasha

I have been doing a bit of parsing through osm log files lately,
and these changes would help me understand the context (current log level)
of the log file, and the nature (log type) of the individual messages.

1. The act of changing the log filter or verbosity level is logged
2. Each log message includes its level.

 From cea8ddbc9b591aefab31a6012a9d43081903ddb5 Mon Sep 17 00:00:00 2001
From: Tim Meier <meier3 at llnl.gov>
Date: Thu, 8 Nov 2007 16:18:41 -0800
Subject: [PATCH] opensm: osm_log - added the log message type to the message

Inserted the log message type (verbosity level) into the
log, so it will be more obvious why a particular message
appears there.  Also, the act of setting or changing the
logging level is logged.

Signed-off-by: Tim Meier <meier3 at llnl.gov>
---
 opensm/include/opensm/osm_log.h |   12 +++++++-----
 opensm/opensm/osm_log.c         |    8 ++++----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/opensm/include/opensm/osm_log.h 
b/opensm/include/opensm/osm_log.h
index 6c487aa..4db96fb 100644
--- a/opensm/include/opensm/osm_log.h
+++ b/opensm/include/opensm/osm_log.h
@@ -99,6 +99,7 @@ typedef uint8_t osm_log_level_t;
 #define OSM_LOG_FUNCS                  0x10
 #define OSM_LOG_FRAMES                 0x20
 #define OSM_LOG_ROUTING                        0x40
+#define OSM_LOG_ALL                            0x7f
 #define OSM_LOG_SYS                    0x80

 /*
@@ -283,6 +284,11 @@ osm_log_init(IN osm_log_t * const p_log,
  * Same as osm_log_init_v2() but without max_size parameter
  */

+void
+osm_log(IN osm_log_t * const p_log,
+       IN const osm_log_level_t verbosity,
+       IN const char *p_str, ...) STRICT_OSM_LOG_FORMAT;
+
 /****f* OpenSM: Log/osm_log_get_level
 * NAME
 *      osm_log_get_level
@@ -326,6 +332,7 @@ static inline void
 osm_log_set_level(IN osm_log_t * const p_log, IN const osm_log_level_t 
level)
 {
        p_log->level = level;
+       osm_log(p_log, OSM_LOG_ALL, "Setting log level to: 0x%02x\n", 
level);
 }

 /*
@@ -386,11 +393,6 @@ extern int osm_log_printf(osm_log_t * p_log, 
osm_log_level_t level,
                          const char *fmt, ...);

 void
-osm_log(IN osm_log_t * const p_log,
-       IN const osm_log_level_t verbosity,
-       IN const char *p_str, ...) STRICT_OSM_LOG_FORMAT;
-
-void
 osm_log_raw(IN osm_log_t * const p_log,
            IN const osm_log_level_t verbosity, IN const char *p_buf);

diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
index 7efe93e..97f8920 100644
--- a/opensm/opensm/osm_log.c
+++ b/opensm/opensm/osm_log.c
@@ -184,19 +184,19 @@ osm_log(IN osm_log_t * const p_log,
              _retry:
                ret =
                    fprintf(p_log->out_port,
-                           "[%02d:%02d:%02d:%03d][%04X] -> %s", st.wHour,
+                           "[%02d:%02d:%02d:%03d][%04X] 0x%02x -> %s", 
st.wHour,
                            st.wMinute, st.wSecond, st.wMilliseconds, pid,
-                           buffer);
+                           verbosity, buffer);
 #else
                pid = pthread_self();
              _retry:
                ret =
                    fprintf(p_log->out_port,
-                           "%s %02d %02d:%02d:%02d %06d [%04X] -> %s",
+                           "%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x 
-> %s",
                            (result.tm_mon <
                             12 ? month_str[result.tm_mon] : "???"),
                            result.tm_mday, result.tm_hour, result.tm_min,
-                           result.tm_sec, usecs, pid, buffer);
+                           result.tm_sec, usecs, pid, verbosity, buffer);
 #endif

                /*  flush log */
--
1.5.1



-- 
Timothy A. Meier
Computer Scientist
ICCD/High Performance Computing
925.422.3341
meier3 at llnl.gov

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-opensm-osm_log-added-the-log-message-type-to-the.patch
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20071108/a9e28b57/attachment.ksh>


More information about the general mailing list