summaryrefslogtreecommitdiffstats
path: root/ci/tools.sh
diff options
context:
space:
mode:
authorMartin Kulhavy <martin.kulhavy@nokia.com>2017-08-15 16:04:11 +0300
committerMartin Kulhavy <martin.kulhavy@nokia.com>2017-08-15 16:04:11 +0300
commit0ab327d6ccdc62f75d6693bea29f3bf41e60c14c (patch)
tree3b8d884bf758c9843a7e7404a51b865c1b36e01a /ci/tools.sh
parentb46de9e8a6d2a87d6e475b6ee9bf66c2c2b9761f (diff)
Improve and highlight logging to console (2)
xtrace produces a lot of output that can be hard to read. This commit uses extra functions for formatted output (info and error), so that they stand out in the log and make it easier for the user to understand what is currently happening. Building up on change #38909: https://gerrit.opnfv.org/gerrit/38909 Change-Id: I0ddf9e0d3a12a62ae45c56d33a8d48c335b618a0 Signed-off-by: Martin Kulhavy <martin.kulhavy@nokia.com>
Diffstat (limited to 'ci/tools.sh')
-rw-r--r--ci/tools.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/ci/tools.sh b/ci/tools.sh
index 4eed361b..ecb2e806 100644
--- a/ci/tools.sh
+++ b/ci/tools.sh
@@ -7,6 +7,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+# include only once
+[ ! -z "$_tools_included" ] && return || readonly _tools_included=true
#######################################
# Echo printing in yellow bold color
@@ -24,3 +26,20 @@ function echo_info { (
echo "${@:1:($#-1)}" -e "$yellow_bold${@: -1}$color_off";
)
}
+
+#######################################
+# Echo error
+# Arguments:
+# Same as for echo
+# Returns:
+# None
+#######################################
+function echo_error { (
+ # don't clutter the script output with the xtrace of the echo command
+ { set +x; } 2> /dev/null
+
+ red_bold='\033[1;31m'
+ color_off='\033[0m'
+ >&2 echo "${@:1:($#-1)}" -e "$red_bold${@: -1}$color_off";
+ )
+}