[openib-general] [PATCH] opensm: handle stdout and stderr in osm_log

Sasha Khapyorsky sashak at voltaire.com
Thu Apr 27 08:03:50 PDT 2006


Hello Hal,

"-" is added as suggested by Greg (handled as stdout).

Sasha.


Handle in osm_log "-", "stdout" or "stderr" words as log file names to
indicate logging to stdout or stderr respectively.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---

 osm/include/opensm/osm_log.h |    7 ++++++-
 osm/opensm/main.c            |    6 +-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/osm/include/opensm/osm_log.h b/osm/include/opensm/osm_log.h
index 8cf8cf1..c4744b5 100644
--- a/osm/include/opensm/osm_log.h
+++ b/osm/include/opensm/osm_log.h
@@ -224,10 +224,15 @@ osm_log_init(
   p_log->level = log_flags;
   p_log->flush = flush;
 
-  if (log_file == NULL)
+  if (log_file == NULL || !strcmp(log_file, "-") ||
+      !strcmp(log_file, "stdout"))
   {
     p_log->out_port = stdout;
   }
+  else if (!strcmp(log_file, "stderr"))
+  {
+    p_log->out_port = stderr;
+  }
   else
   {
     if (accum_log_file)
diff --git a/osm/opensm/main.c b/osm/opensm/main.c
index 6f2a857..d95c314 100644
--- a/osm/opensm/main.c
+++ b/osm/opensm/main.c
@@ -722,11 +722,7 @@ #endif
       break;
 
     case 'f':
-      if (!strcmp(optarg, "stdout"))
-        /* output should be to standard output */
-        opt.log_file = NULL;
-      else
-        opt.log_file = optarg;
+      opt.log_file = optarg;
       break;
 
     case 'e':



More information about the general mailing list