Skip to content

Commit 99bb5df

Browse files
committed
[update] : Added output to stderr
1 parent adb4afa commit 99bb5df

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

tools/msg.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ customized_label=false
1717
nolabel=false
1818
noappname=false
1919
noadjust=false
20+
output="stdout"
2021

2122
_help() {
2223
echo "usage ${0} [option] [type] [message]"
@@ -123,24 +124,28 @@ case ${1} in
123124
"info")
124125
msg_type="type"
125126
textcolor="32"
127+
output="stdout"
126128
[[ "${customized_label}" = false ]] && msg_label="Info"
127129
shift 1
128130
;;
129131
"warn")
130132
msg_type="warn"
131133
textcolor="33"
134+
output="stdout"
132135
[[ "${customized_label}" = false ]] && msg_label="Warning"
133136
shift 1
134137
;;
135138
"debug")
136139
msg_type="debug"
137140
textcolor="35"
141+
output="stdout"
138142
[[ "${customized_label}" = false ]] && msg_label="Debug"
139143
shift 1
140144
;;
141145
"error")
142146
msg_type="error"
143147
textcolor="31"
148+
output="stderr"
144149
[[ "${customized_label}" = false ]] && msg_label="Error"
145150
shift 1
146151
;;
@@ -186,4 +191,16 @@ echo_message() {
186191
echo -ne "${message}\n"
187192
}
188193

189-
echo ${echo_opts} "$(echo_appname)$(echo_type)$(echo_message)"
194+
full_message="$(echo_appname)$(echo_type)$(echo_message)"
195+
196+
case "${output}" in
197+
"stdout")
198+
echo ${echo_opts} "${full_message}" >&1
199+
;;
200+
"stderr")
201+
echo ${echo_opts} "${full_message}" >&2
202+
;;
203+
*)
204+
echo ${echo_opts} "${full_message}" > ${output}
205+
;;
206+
esac

0 commit comments

Comments
 (0)