Add log messages

This commit is contained in:
femsci 2022-04-18 18:33:08 +02:00
parent 88629c9467
commit 1ed7791527
Signed by: femsci
GPG key ID: 08F7911F0E650C67

View file

@ -6,24 +6,33 @@ HOOK_PATH=${HOOK_PATH%/*}
export HOOK_PATH
err_trap() {
echo "Error: $BASH_COMMAND"
}
if [[ $PINCH_DEBUG -eq 1 ]]; then
pdebug() {
echo -e "\033[33m(DEBUG)\033[0m $@"
}
else
else
pdebug() {
:
}
fi
pinfo() {
echo -e "\033[32m=>\033[0m $@"
echo -e "\033[1;32m=>\033[0m $@"
}
pwarn() {
echo -e "\033[1;33m(warning) =>\033[0m $@"
}
perror() {
echo -e "\033[1;31m(error) =>\033[0m $@"
}
err_trap() {
perror "Error during execution of $EXEC_NAME."
}
export -f pinfo pwarn perror
export -f pdebug
export -f err_trap
@ -35,6 +44,7 @@ exec_custom() {
for hook in $(ls $hooks_path); do
if [ -x $hooks_path/$hook ]; then
pdebug "Executing custom hook $hooks_path/$hook"
export EXEC_NAME="custom::$(basename $0)::$hook"
$hooks_path/$hook $HOOK_ARGS
fi
done
@ -44,6 +54,7 @@ exec_all() {
for file in $(ls $1 | sort); do
if [ -x $1/$file ]; then
pdebug "Executing hook $1/$file"
export EXEC_NAME="$(basename $0)::$file"
$1/$file $HOOK_ARGS
fi
done