Вот, написал такой модуль: https://github.com/DRVTiny/bash4-debug-infra
DEBUG_LEVEL=INFO
source /PATH/TO/debug.func
log_open /PATH/TO/LOG_FILE
# This will go to log
info_ 'We are ready to do something nasty'
# And this will be suppressed (according to DEBUG_LEVEL value was set)
debug_ '...but, of course, we are not going to set the world on fire'
You are welcome! :)