#3037 PR merged: Avoid multiple 'set -x' messages for one message output function call (like LogPrint)

Labels: enhancement, fixed / solved / done

jsmeix opened issue at 2023-08-07 08:35:

  • Type: Enhancement

  • Impact: Low

  • Reference to related issue (URL):
    https://github.com/rear/rear/pull/2024

  • How was this pull request tested?
    see below

  • Brief description of the changes in this pull request:

In lib/_input-output-functions.sh
use '2>>/dev/$DISPENSABLE_OUTPUT_DEV'
for all functions that output messages
(i.e. print on the user's terminal or log something)
to avoid that in debugscript mode 'set -x' debug messages
about message output functions appear more than once in the log file,
e.g. for LogPrint 'text' it would appear three times:
one for the initial "LogPrint 'text'" call
plus two more for the resulting "Log 'text'" and "echo 'text" calls.
Now only one 'set -x' debug message for the initial message output
function call appears in the log.

jsmeix commented at 2023-08-07 08:40:

With current master code
for example

# usr/sbin/rear -D savelayout
...
Running workflow savelayout on the normal/original system
...

# less var/log/rear/rear-linux-h9wr.log
...
++ LogPrint 'Running workflow savelayout on the normal/original system'
++ Log 'Running workflow savelayout on the normal/original system'
++ test -w /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log
++ echo '2023-08-07 10:36:29.278419739 Running workflow savelayout on the normal/original system'
2023-08-07 10:36:29.278419739 Running workflow savelayout on the normal/original system
...

With the changes in this pull request:

# usr/sbin/rear -D savelayout
...
Running workflow savelayout on the normal/original system
...

# less var/log/rear/rear-linux-h9wr.log
...
++ LogPrint 'Running workflow savelayout on the normal/original system'
2023-08-07 10:38:52.025895880 Running workflow savelayout on the normal/original system
...

jsmeix commented at 2023-08-07 09:06:

This was since a long time on my personal
TODO list of issues with minor importance
but since https://github.com/rear/rear/pull/3036
those duplicated 'set -x' messages
for one message output function call
now in particular for

LogSecret "Runtime Configuration:$LF$( declare -p )"

made this a real annoyance - at least for me.

With the code in
https://github.com/rear/rear/pull/3036

# usr/sbin/rear -D -e savelayout
...
Dumped all variable values (including possibly confidential values) into ... var/log/rear/rear-linux-h9wr.log
...

# grep 'Runtime Configuration:' var/log/rear/rear-linux-h9wr.log
++ LogSecret 'Runtime Configuration:
++ Log 'Runtime Configuration:
++ echo '2023-08-07 10:50:50.546346825 Runtime Configuration:
2023-08-07 10:50:50.546346825 Runtime Configuration:

# cat -n var/log/rear/rear-linux-h9wr.log | less
...
  1040  ++ LogSecret 'Runtime Configuration:
  1041  declare -- ARCH="Linux-i386"
...
  1678  declare -- verbose="--verbose"'
  1679  ++ test 1
  1680  ++ Log 'Runtime Configuration:
  1681  declare -- ARCH="Linux-i386"
...
  2318  declare -- verbose="--verbose"'
  2319  ++ test -w /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log
  2320  ++ echo '2023-08-07 10:50:50.546346825 Runtime Configuration:
  2321                                declare -- ARCH="Linux-i386"
...
  2958                                declare -- verbose="--verbose"'
  2959  2023-08-07 10:50:50.546346825 Runtime Configuration:
  2960                                declare -- ARCH="Linux-i386"
...
  3597                                declare -- verbose="--verbose"
  3598  ++ LogUserOutput 'Dumped all variable values (including possibly confidential values) into /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log'
  3599  ++ Log 'Dumped all variable values (including possibly confidential values) into /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log'
  3600  ++ test -w /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log
  3601  ++ echo '2023-08-07 10:50:50.592623758 Dumped all variable values (including possibly confidential values) into /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log'
  3602  2023-08-07 10:50:50.592623758 Dumped all variable values (including possibly confidential values) into /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log
  3603  ++ UserOutput 'Dumped all variable values (including possibly confidential values) into /root/rear.dump_variables/var/log/rear/rear-linux-h9wr.log'
...

With the code in
https://github.com/rear/rear/pull/3036
plus the changes in this pull request:

# usr/sbin/rear -D -e savelayout
...
Dumped all variable values (including possibly confidential values) into ... var/log/rear/rear-linux-h9wr.log
...

# grep 'Runtime Configuration:' var/log/rear/rear-linux-h9wr.log
++ LogSecret 'Runtime Configuration:
2023-08-07 10:56:11.210832945 Runtime Configuration:

# cat -n var/log/rear/rear-linux-h9wr.log | less
...
   988  ++ LogSecret 'Runtime Configuration:
   989  declare -- ARCH="Linux-i386"
...
  1626  declare -- verbose="--verbose"'
  1627  2023-08-07 10:56:11.210832945 Runtime Configuration:
  1628                                declare -- ARCH="Linux-i386"
...
  2265                                declare -- verbose="--verbose"
  2266  ++ LogUserOutput 'Dumped all variable values (including possibly confidential values) into /root/rear.dump_variables.old/var/log/rear/rear-linux-h9wr.log'
  2267  2023-08-07 10:56:11.256519252 Dumped all variable values (including possibly confidential values) into /root/rear.dump_variables.old/var/log/rear/rear-linux-h9wr.log
...

jsmeix commented at 2023-08-08 06:45:

@schlomo
thank you for your review!

@rear/contributors
I will merge it today afternoon unless objections appear.


[Export of Github issue for rear/rear.]