Add log messages
This commit is contained in:
parent
88629c9467
commit
1ed7791527
1 changed files with 17 additions and 6 deletions
|
@ -6,24 +6,33 @@ HOOK_PATH=${HOOK_PATH%/*}
|
||||||
|
|
||||||
export HOOK_PATH
|
export HOOK_PATH
|
||||||
|
|
||||||
err_trap() {
|
|
||||||
echo "Error: $BASH_COMMAND"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $PINCH_DEBUG -eq 1 ]]; then
|
if [[ $PINCH_DEBUG -eq 1 ]]; then
|
||||||
pdebug() {
|
pdebug() {
|
||||||
echo -e "\033[33m(DEBUG)\033[0m $@"
|
echo -e "\033[33m(DEBUG)\033[0m $@"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pdebug() {
|
pdebug() {
|
||||||
:
|
:
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pinfo() {
|
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 pdebug
|
||||||
export -f err_trap
|
export -f err_trap
|
||||||
|
|
||||||
|
@ -35,6 +44,7 @@ exec_custom() {
|
||||||
for hook in $(ls $hooks_path); do
|
for hook in $(ls $hooks_path); do
|
||||||
if [ -x $hooks_path/$hook ]; then
|
if [ -x $hooks_path/$hook ]; then
|
||||||
pdebug "Executing custom hook $hooks_path/$hook"
|
pdebug "Executing custom hook $hooks_path/$hook"
|
||||||
|
export EXEC_NAME="custom::$(basename $0)::$hook"
|
||||||
$hooks_path/$hook $HOOK_ARGS
|
$hooks_path/$hook $HOOK_ARGS
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -44,6 +54,7 @@ exec_all() {
|
||||||
for file in $(ls $1 | sort); do
|
for file in $(ls $1 | sort); do
|
||||||
if [ -x $1/$file ]; then
|
if [ -x $1/$file ]; then
|
||||||
pdebug "Executing hook $1/$file"
|
pdebug "Executing hook $1/$file"
|
||||||
|
export EXEC_NAME="$(basename $0)::$file"
|
||||||
$1/$file $HOOK_ARGS
|
$1/$file $HOOK_ARGS
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue