| # 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' |
| color_success='\033[32m' |
| |
| |
| log_e() |
| { |
| echo "${color_error}$*${color_reset}" >&2 |
| exit 1 |
| } |
| |
| |
| log_w() |
| { |
| echo "${color_warning}$*${color_reset}" |
| } |
| |
| |
| log_i() |
| { |
| echo "$*" |
| } |
| |
| |
| log_v() |
| { |
| if [ -n "${VERBOSE}" ] ; then |
| echo "$*" |
| fi |
| } |
| |
| |
| log_bold() |
| { |
| echo "\n${color_bold}$*${color_reset}" |
| } |
| |
| |
| [ -n "${DEBUG}" ] && set -x || true |