Logging build script output to tty and log

I’ve written down the requirements for a perfect log command:

  • show stdout/stderr of the script in tty while the script is running
  • show colors produced by the script in tty while the script is running
  • create a log file of all stdout/stderr the script produced
  • have the log without colors
  • don’t break the ability to read input from stdin

Apparently no such jack of all trades device has been found. The following command fulfills all requirements everything, but stripping colors from the log.

sudo script -a -f ~/log -c "./whonix_build --build --tor-gateway"

Stripping the color from the log is possible as well.

logname=~/log ; cat $logname | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' | col -b > $logname-processed

(source); (There might be other methods or entirely different (better/perfect) approaches to the log issue.

Haven’t tested a full build using the script approach yet.

Does this suffice?

First one look great, second one looks like a nightmare :smiley:

I’ll give both a test when time allows.

script: unrecognized option ‘–build’.

Can we disable colors in the Whonix build script?

[quote=“Patrick, post:7, topic:89”][quote author=Occq link=topic=70.msg605#msg605 date=1393189348]
There is one problem with the build script error handler.

If the build fails in the middle (for whatever reason, like if you forgot to set disk space to more than 8GB. Stupid mistake) the script keeps running because it requires user input. That is highly impractical for those of us who use input log redirection. We don’t see the question, we can’t answer it.

"Please enter c and press enter to continue..
"Please enter to cleanup and exit"

Short term solution is to delete user input option and end the script when it breaks (no continue choice, direct auto exit).

Oh and bare metal was run successfull with India as the location (the same settings failed in the last version) so update-locale seems fixed.
[/quote]

I see. This is non-ideal. Should documented for now. And improved for Whonix 8 + 1.

I don’t want to entirely remove this feature. Has proven very useful in development. Could be disabled by default and enabled with a build configuration.[/quote]

So far the disabled-by-default option seems most easy to implement.

Command needs to be quotes. Fixed in original post.

sudo script -a -f ~/log -c "./whonix_build --build --tor-gateway"

With the script (typescript) logging method working, is there still benefit in disabling user input in the error handler?

Why disable colors? Because it may help to strip colors from the log?

Colors are configured in help-steps/pre in function “colors”. By not running the “colors” function (which could be configured by a command line option, environment variable and/or build configuration), variables such as ${red} would be empty and therefore not producing any output, i.e. no color.

I personally like having colors in tty output. Makes following the process, noticing important messages, navigation, debugging simpler.

Colors encoding ([[0m ) that appears in a log are disturbing (IMO). If it’s either no colors or that encoding (00;32m) I would rather go with no colors.

Disabling user input by default gives us time to figure out something that works.

I preferred an alternative command or log wrapper script, that can do that. There must be some way.

What doesn’t work? The colors in the log? I consider this a minor issue. Is it that bad to run a single command to strip colors from it?

Colors in Whonix’s build script can also be disabled by running.

No kidding. :wink: (It’s a standard feature, looks like.)

Before building. (Don’t forget to use adding -E to sudo then (sudo -E …) then, because environment variables need to preserved.)