From e3c4dba8504d77f24c4a85314e343fc43a753d33 Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Wed, 6 Dec 2023 10:25:01 +0100 Subject: [PATCH] added a mechanism di disable debug messages work related to https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=2713 --- home/bin/deboco | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/home/bin/deboco b/home/bin/deboco index 618aa85..1d88f3f 100755 --- a/home/bin/deboco +++ b/home/bin/deboco @@ -15,32 +15,46 @@ readonly COLOR_RESET='\033[0m' RETURNCODE_SUCCESS=0 RETURNCODE_ERROR=1 - +DEFAULT_PYTHON_PATH='/usr/bin/python3' +PYTHON_PATH='' +readonly LOG_LEVEL_ERROR=0 +readonly LOG_LEVEL_WARNING=1 +readonly LOG_LEVEL_INFO=2 +readonly LOG_LEVEL_DEBUG=3 +LOG_LEVEL=$LOG_LEVEL_INFO log() { local log_type="$1" # 'debug', 'info', 'warning' or 'error' local message="$2" local message_color='' + local message_level='' case "$log_type" in 'error') message_color="$COLOR_RED" + message_level="$LOG_LEVEL_ERROR" ;; 'warning') message_color="$COLOR_YELLOW" + message_level="$LOG_LEVEL_WARNING" ;; 'info') message_color="$COLOR_BLUE" + message_level="$LOG_LEVEL_INFO" ;; 'debug') message_color="$COLOR_PURPLE" + message_level="$LOG_LEVEL_DEBUG" ;; *) echo "unexpected log type $log_type" exit "$RETURNCODE_ERROR" esac - printf "%b : %s\n" "${message_color}${log_type}${COLOR_RESET}" "$message" + if [ "$message_level" -le "$LOG_LEVEL" ] + then + printf "%b : %s\n" "${message_color}${log_type}${COLOR_RESET}" "$message" + fi } replace_in_file()