37 lines
553 B
Bash
37 lines
553 B
Bash
#!/bin/sh
|
|
|
|
|
|
# levels:
|
|
# DEBUG = 0
|
|
# INFO = 1
|
|
# WARN = 2
|
|
# ERROR = 3
|
|
A3_LOG_LEVEL=${A3_LOG_LEVEL:-1}
|
|
|
|
__a3_log_level_to_text() {
|
|
case $1 in
|
|
0) echo "debug" ;;
|
|
1) echo "info" ;;
|
|
2) echo "warn" ;;
|
|
3) echo "error" ;;
|
|
4) echo "fatal" ;;
|
|
esac
|
|
}
|
|
|
|
__a3_log() {
|
|
level=$1
|
|
shift
|
|
if [ $level -ge $A3_LOG_LEVEL ]; then
|
|
echo "[$(__a3_log_level_to_text $level)] $@"
|
|
fi
|
|
}
|
|
|
|
alias LOGD="__a3_log 0"
|
|
alias LOGI="__a3_log 1"
|
|
alias LOGW="__a3_log 2"
|
|
alias LOGE="__a3_log 3"
|
|
|
|
fatal_log() {
|
|
__a3_log 4 $@
|
|
exit 1
|
|
}
|