From 7f15e27e3dea623fefa485f04f3634289b3c626d Mon Sep 17 00:00:00 2001 From: tradke Date: Tue, 13 Dec 2005 16:31:40 +0000 Subject: Extend CCTK_VWarn() so that, if Cactus::cctk_full_warnings is set to true, it also prints the hostname of the originating warning message. This information comes in handy when debugging a problem on clusters by directly logging into the nodes. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4214 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/main/WarnLevel.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/WarnLevel.c b/src/main/WarnLevel.c index b052f9dd..ffcad740 100644 --- a/src/main/WarnLevel.c +++ b/src/main/WarnLevel.c @@ -35,6 +35,7 @@ #include "cctki_WarnLevel.h" #include "util_String.h" +#include "util_Network.h" static const char *rcsid = "$Header$"; CCTK_FILEVERSION(main_WarnLevel_c); @@ -53,6 +54,8 @@ CCTK_FILEVERSION(main_WarnLevel_c); #define BOLD_OFF "" #endif +/* maximum buffer length to hold the hostname */ +#define MAXNAMELEN 255 /******************************************************************** ********************* External Routines ********************** @@ -471,6 +474,7 @@ int CCTK_VWarn (int level, int msg_size; char *message = NULL; + char hostname[MAXNAMELEN+1]; /* Start generating message only if the warbcallback list is not NULL */ if(warncallbacks) @@ -503,6 +507,7 @@ int CCTK_VWarn (int level, { myproc = CCTK_MyProc(NULL); + Util_GetHostName (hostname, MAXNAMELEN); cctk_full_warnings_ptr = CCTK_ParameterGet ("cctk_full_warnings", "Cactus", ¶m_type); @@ -534,10 +539,10 @@ int CCTK_VWarn (int level, if (level <= error_level || cctk_full_warnings) { - fprintf (stderr, "WARNING level %d in thorn %s processor %d\n" + fprintf (stderr, "WARNING level %d in thorn %s processor %d host %s\n" " (line %d of %s): \n" " ->", - level, thorn, myproc, line, file); + level, thorn, myproc, hostname, line, file); } else { @@ -567,10 +572,10 @@ int CCTK_VWarn (int level, if (level <= error_level || cctk_full_warnings) { - fprintf (stdout, "WARNING level %d in thorn %s processor %d\n" + fprintf (stdout, "WARNING level %d in thorn %s processor %d host %s\n" " (line %d of %s): \n" " ->", - level, thorn, myproc, line, file); + level, thorn, myproc, hostname, line, file); } else { -- cgit v1.2.3