Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Aug 8, 2023

Conversation

jsmeix
Copy link
Member

@jsmeix jsmeix commented Aug 7, 2023

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.

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 "Print 'text" calls.
Now only one 'set -x' debug message for the initial message output function call appears in the log.
@jsmeix jsmeix added the enhancement Adaptions and new features label Aug 7, 2023
@jsmeix jsmeix added this to the ReaR v2.8 milestone Aug 7, 2023
@jsmeix jsmeix self-assigned this Aug 7, 2023
@jsmeix
Copy link
Member Author

jsmeix commented Aug 7, 2023

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
Copy link
Member Author

jsmeix commented Aug 7, 2023

This was since a long time on my personal
TODO list of issues with minor importance
but since #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
#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
#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 jsmeix requested a review from a team August 7, 2023 09:35
@jsmeix
Copy link
Member Author

jsmeix commented Aug 8, 2023

@schlomo
thank you for your review!

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

@jsmeix jsmeix merged commit da08665 into master Aug 8, 2023
15 checks passed
@jsmeix jsmeix deleted the jsmeix-less-messaging-debug branch August 8, 2023 13:39
jsmeix added a commit that referenced this pull request Dec 21, 2023
In lib/_input-output-functions.sh
have the whole function body of the Log function within
{ ... } 2>>/dev/$DISPENSABLE_OUTPUT_DEV
to have no 'set -x' messages for the Log function.
In 5ed5b2e
a 'test' command was prepended in the Log function body
outside of { ... } 2>>/dev/$DISPENSABLE_OUTPUT_DEV
which contradicts the intent of the later
#3037
to have no 'set -x' messages for all functions
in lib/_input-output-functions.sh that output messages
jsmeix referenced this pull request Dec 21, 2023
Some more minor fixes for early Error() in usr/sbin/rear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adaptions and new features fixed / solved / done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants