Commit e41bc9a3 authored by Michael Völske's avatar Michael Völske

add optional DEBUG logging also for bash scripts

parent 59e20eae
......@@ -31,7 +31,7 @@ logInfo() {
# Printout debug info if debug enabled.
#
logDebug() {
echo -e "\033[94m[DEBUG]\033[0m $@" 1>&2;
$(is_var_set WEBIS_DEBUG) && echo -e "\033[94m[DEBUG]\033[0m $@" 1>&2;
}
#
......@@ -254,6 +254,18 @@ get_group() {
stat -c %G "$@"
}
#
# Check if a variable is set
#
# \params $@ NAME
# \return (exit code)
# Example:
# is_var_set FOO && echo "yay! FOO is set!"
is_var_set() {
[ ! -z ${!1+x} ]
}
#
# Printout settings and check configuration.
#
......
......@@ -19,6 +19,10 @@ def set_verbose_logging(is_enabled):
_log_settings['debug'] = is_enabled
def is_verbose_logging():
return _log_settings['debug']
def colorred(m):
return "\033[91m" + m + "\033[0m"
......
......@@ -119,6 +119,8 @@ def run_subcommand(subcommand, subcommandpath, params=[]):
pp = os.environ.get('PYTHONPATH')
webis_dir = os.path.dirname(os.path.realpath(__file__))
os.environ['PYTHONPATH'] = webis_dir if pp is None else pp + ':' + webis_dir
if is_verbose_logging():
os.environ['WEBIS_DEBUG'] = '1'
cmd = " ".join([subcommandpath] + params)
return_value = os.system(cmd)
if return_value == 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment