diff --git a/lib/log.bash b/lib/log.bash index 882bc5f9..105c9064 100644 --- a/lib/log.bash +++ b/lib/log.bash @@ -18,10 +18,11 @@ function _log_general() { about 'Internal function used for logging, uses BASH_IT_LOG_PREFIX as a prefix' param '1: color of the message' - param '2: message to log' + param '2: log level to print before the prefix' + param '3: message to log' group 'log' - message=${BASH_IT_LOG_PREFIX}$2 + message=$2${BASH_IT_LOG_PREFIX}$3 _has_colors && echo -e "$1${message}${echo_normal}" || echo -e "${message}" } @@ -33,7 +34,7 @@ function _log_debug() group 'log' [[ "$BASH_IT_LOG_LEVEL" -ge $BASH_IT_LOG_LEVEL_ALL ]] || return 0 - _log_general "${echo_green}" "DEBUG: $1" + _log_general "${echo_green}" "DEBUG: " "$1" } function _log_warning() @@ -44,7 +45,7 @@ function _log_warning() group 'log' [[ "$BASH_IT_LOG_LEVEL" -ge $BASH_IT_LOG_LEVEL_WARNING ]] || return 0 - _log_general "${echo_yellow}" " WARN: $1" + _log_general "${echo_yellow}" " WARN: " "$1" } function _log_error() @@ -55,5 +56,5 @@ function _log_error() group 'log' [[ "$BASH_IT_LOG_LEVEL" -ge $BASH_IT_LOG_LEVEL_ERROR ]] || return 0 - _log_general "${echo_red}" "ERROR: $1" + _log_general "${echo_red}" "ERROR: " "$1" } diff --git a/test/lib/log.bats b/test/lib/log.bats index ad1cdf07..5afb9195 100644 --- a/test/lib/log.bats +++ b/test/lib/log.bats @@ -82,5 +82,5 @@ load ../../lib/log BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL BASH_IT_LOG_PREFIX="nice: prefix: " run _log_debug "test test test" - assert_output "nice: prefix: DEBUG: test test test" + assert_output "DEBUG: nice: prefix: test test test" }