shell-base/modules/utility/debug.lib

42 lines
1.0 KiB
Bash

#!/bin/bash
# TODO allow debug to have managment flags and levels
function debug () {
[[ $BASH_DEBUG ]] && echo -e "#### DEBUG ####\n $@ \n#####" >&2
}
# alias debug_on="sudo -i uncomment BASH_DEBUG /etc/bash.bashrc"
# alias debug_off="sudo -i comment BASH_DEBUG /etc/bash.bashrc"
# *************** DEBUGGING ***********************
# module_load debug
# if [[ $? -ne 0 ]]; then
# echo "unable to load a 'debug' module using a noop for debug function"
# # noop
# function debug () {
# :
# }
# fi
# [[ ! $- == *i* ]] && exec >> ~/logs/load.log && exec 2>&1
# export BASH_DEBUG=true
# uncomment for debugging
# echo $USER running load script in $DIR
# echo callers
# caller
# echo $(ps -o comm= $PPID)
# echo -----
# echo $BASH_SHELL_DIRS
# ******************END DEBUGGING *******************************
# ***************** LOGGING *****************
# function nilog () {
# [[ ! $- == *i* ]] && echo -e "-----\n $USER $*" &>> ~/logs/load.log
# }
# nilog "called load.sh $(date)"
# nilog caller: $(caller)
# nilog pid: $(ps -o comm= $PPID)
# *