added a mechanism di disable debug messages
work related to https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=2713
This commit is contained in:
		
							parent
							
								
									9def80af12
								
							
						
					
					
						commit
						e3c4dba850
					
				|  | @ -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() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue