Skip to content

Commit a56728d

Browse files
authored
Merge pull request #13 from Tirsvad/main
Visuel change
2 parents 7901c39 + d32ab03 commit a56728d

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/Logger/run.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ tcli_logger_infoscreenDone() {
7171
## @param string error message part 1 red color
7272
## @param string error message part 2 blue color
7373
## @param string error message part 3 red color
74+
## @param string function or other notice in front of message
7475
tcli_logger_infoscreenFailed() {
75-
local _errormsg="${1:-} ${2:-} ${3:-}"
76+
local -a _errormsg
77+
# ="${1:-} ${2:-} ${3:-}"
78+
[ ${1:-} ] && _errormsg=($1)
79+
[ ${2:-} ] && _errormsg+=($2)
80+
[ ${3:-} ] && _errormsg+=($3)
7681
[ ${TCLI_LOGGER_INFOSCREEN_WARN} == 1 ] && TCLI_LOGGER_INFOSCREEN_WARN=0
7782
printf "\r\033[1C${TCLI_LOGGER_RED}FAILED${TCLI_LOGGER_NC}\n"
78-
# [ ${1:-} ] && printf "${TCLI_LOGGER_RED}${1}"
79-
# [ ${2:-} ] && printf " ${TCLI_LOGGER_BLUE}${2}"
80-
# [ ${3:-} ] && printf " ${TCLI_LOGGER_RED}${3}"
81-
# printf "${TCLI_LOGGER_NC}\n"
82-
[ ! -z "${_errormsg:-}" ] && printf "${_errormsg}" >&2
83+
tcli_logger_file_error $(echo ${_errormsg[@]}) ${4:-}
8384
}
8485

8586
## @fn tcli_logger_infoscreenFailedExit()
@@ -90,8 +91,14 @@ tcli_logger_infoscreenFailed() {
9091
## @param string error message part 2 blue color
9192
## @param string error message part 3 red color
9293
## @param interger exit code (default is 1)
94+
## @param string error cause
9395
tcli_logger_infoscreenFailedExit() {
94-
tcli_logger_infoscreenFailed "${1:-}" "${2:-}" "${3:-}"
96+
tcli_logger_infoscreenFailed "${1:-}" "${2:-}" "${3:-}" "${5:-}"
97+
[ ${4:-} ] && printf "${TCLI_LOGGER_RED}${1} : "
98+
[ ${1:-} ] && printf "${TCLI_LOGGER_RED}${1}"
99+
[ ${2:-} ] && printf " ${TCLI_LOGGER_BLUE}${2}"
100+
[ ${3:-} ] && printf " ${TCLI_LOGGER_RED}${3}"
101+
printf "${TCLI_LOGGER_NC}\n"
95102
exit ${4:-1}
96103
}
97104

@@ -158,7 +165,7 @@ tcli_logger_title() {
158165
## @details
159166
## **Info to log file**
160167
## @param string message
161-
## @param string function or other notice before message
168+
## @param string function or other notice in front of message
162169
tcli_logger_file_info() {
163170
tcli_logger_file "Info" ${1:-} ${2:-}
164171
}

src/Test/test.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ test_tcli_logger_file_error() {
113113
[ $(grep -R "Error >>> error msg" ./log/mytest.log) ] && info_passed || info_failed
114114
}
115115

116+
test_tcli_logger_infoscreenFailed() {
117+
local _result
118+
info "tcli_logger_infoscreenFailed"
119+
_result=$( tcli_logger_infoscreenFailedExit "Must be run as" "root" "" 100 "Unprivileged user")
120+
[ $(grep -R "Error >>> Unprivileged user : Must be run as root" ./log/mytest.log) ] && info_passed || info_failed
121+
# TODO test result
122+
}
123+
116124
## @fn info_report()
117125
## @details
118126
## **Generate test repport**
@@ -130,7 +138,8 @@ test_tcli_logger_title
130138
test_tcli_logger_file_info
131139
test_tcli_logger_file_warn
132140
test_tcli_logger_file_error
141+
test_tcli_logger_infoscreenFailed
133142

134143
info_report
135144

136-
rm -rf ${TEST_PATH_SCRIPTDIR}/log
145+
# rm -rf ${TEST_PATH_SCRIPTDIR}/log

0 commit comments

Comments
 (0)