diff options
author | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-12-20 10:44:02 +0000 |
---|---|---|
committer | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-12-20 10:44:02 +0000 |
commit | 02a38964d6b236ed28850456eaeb4f7a89cdd4ae (patch) | |
tree | f48d74a4f111ea23fe75885bd3151e8c08665684 /src/main/WarnLevel.c | |
parent | 34f683e44bd5f40484469692a152b6661a84abd5 (diff) |
Implement steerable boolean parameter Cactus::highlight_warning_messages
which turns on/off highlighting of CCTK warning messages using ANSI escape
sequences. Default is on.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@3937 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/WarnLevel.c')
-rw-r--r-- | src/main/WarnLevel.c | 120 |
1 files changed, 88 insertions, 32 deletions
diff --git a/src/main/WarnLevel.c b/src/main/WarnLevel.c index 8a3a100b..565d95e7 100644 --- a/src/main/WarnLevel.c +++ b/src/main/WarnLevel.c @@ -39,17 +39,19 @@ CCTK_FILEVERSION(main_WarnLevel_c); /******************************************************************** - ********************* Macros ********************** + ********************* Macros ********************** ********************************************************************/ -/* warning messages are printed hightlighted if possible */ +/* Escape sequences to highlight warning messages. + */ #ifndef WIN32 -#define BOLDON "\033[1m" -#define BOLDOFF "\033[0m" +#define BOLD_ON "\033[1m" +#define BOLD_OFF "\033[0m" #else -#define BOLDON "" -#define BOLDOFF "" +#define BOLD_ON "" +#define BOLD_OFF "" #endif + /******************************************************************** ********************* External Routines ********************** ********************************************************************/ @@ -383,7 +385,7 @@ int CCTK_VWarn (int level, const char *format, ...) { - const CCTK_INT *cctk_full_warnings; + const CCTK_INT *cctk_full_warnings, *highlight_warning_messages; int param_type; int myproc; va_list ap; @@ -394,37 +396,71 @@ int CCTK_VWarn (int level, fflush(stdout); myproc = CCTK_MyProc(NULL); - cctk_full_warnings = CCTK_ParameterGet ("cctk_full_warnings", "Cactus", - ¶m_type); - if ((level <= error_level) || (cctk_full_warnings && *cctk_full_warnings)) + cctk_full_warnings = + CCTK_ParameterGet ("cctk_full_warnings", "Cactus", ¶m_type); + highlight_warning_messages = + CCTK_ParameterGet ("highlight_warning_messages", "Cactus", ¶m_type); + if (level <= error_level || cctk_full_warnings) { - fprintf (stderr, BOLDON - "WARNING level %d in thorn %s processor %d" - BOLDOFF - "\n" - " (line %d of %s): \n" - " -> ", - level, thorn, myproc, line, file); - if (myproc) + if (*highlight_warning_messages) + { + fprintf (stderr, BOLD_ON "WARNING level %d in thorn %s processor %d" + BOLD_OFF "\n" + " (line %d of %s): \n" + " -> ", + level, thorn, myproc, line, file); + } + else { - fprintf (stdout, BOLDON - "WARNING level %d in thorn %s processor %d" - BOLDOFF - "\n" + fprintf (stderr, "WARNING level %d in thorn %s processor %d\n" " (line %d of %s): \n" " -> ", level, thorn, myproc, line, file); } + if (myproc) + { + if (*highlight_warning_messages) + { + fprintf (stdout, BOLD_ON "WARNING level %d in thorn %s processor %d" + BOLD_OFF "\n" + " (line %d of %s): \n" + " -> ", + level, thorn, myproc, line, file); + } + else + { + fprintf (stdout, "WARNING level %d in thorn %s processor %d\n" + " (line %d of %s): \n" + " -> ", + level, thorn, myproc, line, file); + } + } } else { - fprintf (stderr, BOLDON "WARNING[L%d,P%d] (%s):" BOLDOFF " ", - level, myproc, thorn); - if (myproc) + if (*highlight_warning_messages) + { + fprintf (stderr, BOLD_ON "WARNING[L%d,P%d] (%s):" BOLD_OFF " ", + level, myproc, thorn); + } + else { - fprintf (stdout, BOLDON "WARNING[L%d,P%d] (%s):" BOLDOFF " ", + fprintf (stderr, "WARNING[L%d,P%d] (%s): ", level, myproc, thorn); } + if (myproc) + { + if (*highlight_warning_messages) + { + fprintf (stdout, BOLD_ON "WARNING[L%d,P%d] (%s):" BOLD_OFF " ", + level, myproc, thorn); + } + else + { + fprintf (stdout, "WARNING[L%d,P%d] (%s): ", + level, myproc, thorn); + } + } } va_start (ap, format); @@ -495,14 +531,24 @@ int CCTK_ParameterLevel (void) @@*/ int CCTK_ParamWarn (const char *thorn, const char *message) { - const CCTK_INT *cctk_strong_param_check; + const CCTK_INT *cctk_strong_param_check, *highlight_warning_messages; int param_type; cctk_strong_param_check = CCTK_ParameterGet ("cctk_strong_param_check", "Cactus", ¶m_type); + highlight_warning_messages = CCTK_ParameterGet ("highlight_warning_messages", + "Cactus", ¶m_type); fflush (stdout); - fprintf (stderr, BOLDON "PARAM %s (%s):" BOLDOFF " %s\n", - *cctk_strong_param_check ? "ERROR" : "WARNING", thorn, message); + if (*highlight_warning_messages) + { + fprintf (stderr, BOLD_ON "PARAM %s (%s):" BOLD_OFF " %s\n", + *cctk_strong_param_check ? "ERROR" : "WARNING", thorn, message); + } + else + { + fprintf (stderr, "PARAM %s (%s): %s\n", + *cctk_strong_param_check ? "ERROR" : "WARNING", thorn, message); + } fflush (stderr); param_errors++; @@ -555,14 +601,24 @@ int CCTK_VParamWarn (const char *thorn, ...) { va_list ap; - const CCTK_INT *cctk_strong_param_check; + const CCTK_INT *cctk_strong_param_check, *highlight_warning_messages; int param_type; cctk_strong_param_check = CCTK_ParameterGet ("cctk_strong_param_check", "Cactus", ¶m_type); + highlight_warning_messages = CCTK_ParameterGet ("highlight_warning_messages", + "Cactus", ¶m_type); fflush (stdout); - fprintf (stderr, BOLDON "PARAM %s (%s)" BOLDOFF ": ", - *cctk_strong_param_check ? "ERROR" : "WARNING", thorn); + if (*highlight_warning_messages) + { + fprintf (stderr, BOLD_ON "PARAM %s (%s)" BOLD_OFF ": ", + *cctk_strong_param_check ? "ERROR" : "WARNING", thorn); + } + else + { + fprintf (stderr, "PARAM %s (%s): ", + *cctk_strong_param_check ? "ERROR" : "WARNING", thorn); + } va_start (ap, format); vfprintf (stderr, format, ap); |