blob: ddf6ecbfeedff0a5c453577700bc81897c538528 [file] [log] [blame]
# shellcheck shell=bash
# Copyright 2018-2021 Fairphone B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Globals:
# DEBUG
# VERBOSE
set -e
DEBUG="${DEBUG:-}"
VERBOSE="${VERBOSE:-}"
# Echo formatting
color_error='\033[31m'
color_warning='\033[33m'
color_bold='\033[1m'
color_reset='\033[0m'
_repo_project_tag() {
if [ "${REPO_PROJECT:-}" ]; then
echo "[${REPO_PROJECT}]"
fi
}
log_e()
{
echo "${color_error}$(_repo_project_tag) $*${color_reset}" >&2
exit 1
}
log_w()
{
echo "${color_warning}$(_repo_project_tag)$ $*${color_reset}"
}
log_i()
{
echo "$(_repo_project_tag)$ $*"
}
log_v()
{
if [ -n "${VERBOSE}" ] ; then
echo "$(_repo_project_tag)$ $*"
fi
}
log_bold()
{
printf "\n${color_bold}$(_repo_project_tag)$ %s${color_reset}" "$*"
}
if [ -n "${DEBUG:-}" ]; then
set -x
fi