orcli/src/lib/logging.sh

22 lines
657 B
Bash
Raw Normal View History

2022-04-12 18:26:43 +02:00
# print messages to STDERR
# shellcheck shell=bash
function error() {
echo >&2 "[$(date +'%Y-%m-%dT%H:%M:%S')] ERROR: $1"
shift
2023-10-26 07:16:15 +02:00
for msg in "$@"; do echo >&2 " $msg"; done
if [[ -f "$OPENREFINE_TMPDIR/openrefine.log" ]]; then
echo >&2 "last 50 lines of OpenRefine's server log:"
echo >&2 "-----------------------------------------"
tail >&2 -50 "$OPENREFINE_TMPDIR/openrefine.log"
echo >&2 "-----------------------------------------"
fi
2022-04-12 18:26:43 +02:00
exit 1
}
function log() {
2022-11-14 23:46:18 +01:00
if ! [[ ${args[--quiet]} || $ORCLI_QUIET ]]; then
2022-04-20 12:27:53 +02:00
echo >&2 "[$(date +'%Y-%m-%dT%H:%M:%S')] $1"
shift
for msg in "$@"; do echo >&2 " $msg"; done
fi
2022-04-12 18:26:43 +02:00
}