Skip to content

Add color to output#630

Merged
bendudson merged 4 commits intodschwoerer-verbosityfrom
log-color
Sep 7, 2017
Merged

Add color to output#630
bendudson merged 4 commits intodschwoerer-verbosityfrom
log-color

Conversation

@bendudson
Copy link
Contributor

Adds a shell script and command-line option ("-c") to color BOUT++ output

  • bout-log-color is a shell script which uses sed to insert text color escape codes. This currently highlights:

    1. Any word "warning" or "error" (case insensitive) is turned red
    2. The word "default" after options is turned blue
    3. The phrase "Command line" after options is turned green

    The aim of this is to highlight important things to note
    i.e. when something might be wrong; when the code has set something
    for you, and for the few settings which you override on the command line

    If the BOUT-dev "bin" directory is in PATH, then existing log files can be printed in color using:

    $ cat BOUT.log.0 | bout-log-color

  • A command-line option "-c" has been added, which pipes stdout through bout-log-color. This uses posix functions, so should be quite portable. This functionality can be disabled in configure with "--disable-color" if needed.

An issue is that if "-c" is used, but bout-log-color is not in PATH, then the code exits. The popen command succeeds, returning a valid pipe, even though the shell command failed.

* bout-log-color is a shell script which uses sed
  to insert text color escape codes. This currently highlights:

  1. Any word "warning" or "error" (case insensitive) is turned red
  2. The word "default" after options is turned blue
  3. The phrase "Command line" after options is turned green

  The aim of this is to highlight important things to note
  i.e. when something might be wrong; when the code has set something
  for you, and for the few settings which you override on the command line

  If the BOUT-dev "bin" directory is in PATH, then existing log files
  can be printed using:

  $ cat BOUT.log.0 | bout-log-color

* A command-line option "-c" has been added, which pipes stdout
  through bout-log-color. This uses posix functions, so should be
  quite portable. This functionality can be disabled in configure
  with "--disable-color" if needed.

An issue is that if "-c" is used, but bout-log-color is not in PATH,
then the code exits. The popen command succeeds, returning a valid
pipe, even though the shell command failed.
@d7919
Copy link
Member

d7919 commented Jul 27, 2017

Could the full path to bout-log-color be defined at the configure stage so we can use the full path when opening the pipe? This might reduce issues with not having path set correctly, although still not avoiding all possible issues (e.g. with the script not working for other unlikely reasons).

configure.ac Outdated
echo "Segmentation fault handling disabled"
fi

if test "$enable_signal" != "no"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable_signal should be enable_color

src/bout++.cxx Outdated
" -v \t\tIncrease verbosity\n"
" -q \t\tDecrease verbosity\n"
#ifdef LOGCOLOR
" -c \t\tColor output using bout-log-color\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide long version as well? Both -c and --color?

copy-paste error, using enable_signal rather than enable_color in
configure.

--color long option added, with same effect as -c
Moved the stdout pipe to after MPI is initialised,
then only if MYPE == 0
@bendudson bendudson merged commit c685f12 into dschwoerer-verbosity Sep 7, 2017
@bendudson bendudson deleted the log-color branch September 7, 2017 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants