@@ -55,8 +55,15 @@ function _bash-it-log-message() {
5555 param ' 3: message to log'
5656 group ' log'
5757
58- message=" $2 ${BASH_IT_LOG_PREFIX:- default: } $3 "
59- _has_colors && echo -e " $1 ${message}${echo_normal:- } " || echo -e " ${message} "
58+ local prefix=" ${BASH_IT_LOG_PREFIX:- default} "
59+ local color=" ${1-${echo_cyan:- } } "
60+ local level=" ${2:- TRACE} "
61+ local message=" ${level%: } : ${prefix%: } : $3 "
62+ if _has_colors; then
63+ printf ' %b%s%b\n' " ${color} " " ${message} " " ${echo_normal:- } "
64+ else
65+ printf ' %s\n' " ${message} "
66+ fi
6067}
6168
6269function _log_debug() {
@@ -65,8 +72,9 @@ function _log_debug() {
6572 example ' $ _log_debug "Loading plugin git..."'
6673 group ' log'
6774
68- [[ " ${BASH_IT_LOG_LEVEL:- 0} " -ge " ${BASH_IT_LOG_LEVEL_INFO?} " ]] || return 0
69- _bash-it-log-message " ${echo_green:- } " " DEBUG: " " $1 "
75+ if [[ " ${BASH_IT_LOG_LEVEL:- 0} " -ge " ${BASH_IT_LOG_LEVEL_INFO?} " ]]; then
76+ _bash-it-log-message " ${echo_green:- } " " DEBUG: " " $1 "
77+ fi
7078}
7179
7280function _log_warning() {
@@ -75,8 +83,9 @@ function _log_warning() {
7583 example ' $ _log_warning "git binary not found, disabling git plugin..."'
7684 group ' log'
7785
78- [[ " ${BASH_IT_LOG_LEVEL:- 0} " -ge " ${BASH_IT_LOG_LEVEL_WARNING?} " ]] || return 0
79- _bash-it-log-message " ${echo_yellow:- } " " WARN: " " $1 "
86+ if [[ " ${BASH_IT_LOG_LEVEL:- 0} " -ge " ${BASH_IT_LOG_LEVEL_WARNING?} " ]]; then
87+ _bash-it-log-message " ${echo_yellow:- } " " WARN: " " $1 "
88+ fi
8089}
8190
8291function _log_error() {
@@ -85,6 +94,7 @@ function _log_error() {
8594 example ' $ _log_error "Failed to load git plugin..."'
8695 group ' log'
8796
88- [[ " ${BASH_IT_LOG_LEVEL:- 0} " -ge " ${BASH_IT_LOG_LEVEL_ERROR?} " ]] || return 0
89- _bash-it-log-message " ${echo_red:- } " " ERROR: " " $1 "
97+ if [[ " ${BASH_IT_LOG_LEVEL:- 0} " -ge " ${BASH_IT_LOG_LEVEL_ERROR?} " ]]; then
98+ _bash-it-log-message " ${echo_red:- } " " ERROR: " " $1 "
99+ fi
90100}
0 commit comments