How do I customize the log format for "set -x" in a bash / shell script?

I would like to dump all my "set -x" output to a syslog file. However, the syslog file has its own custom format.

But there is no formatting for the set -x output.

How can i do this?

0


source to share


1 answer


If you look print_cmd.c

in the Bash source code, you will see that the output format is set -x

not configurable.

You can capture the signal DEBUG

to implement your own custom logging like



trap 'logger -p user.debug -t SHELLSCRIPT -- "$BASH_COMMAND" || :' DEBUG

      

send all commands to syslog using tool user

, level DEBUG

and tag SHELLSCRIPT

.

+2


source







All Articles