feat: a3 and other things

This commit is contained in:
Strix 2024-06-06 02:00:49 +02:00
parent dd7516e6d7
commit 4be03b9764
7 changed files with 180 additions and 82 deletions

View file

@ -1,16 +1,36 @@
#!/bin/sh
__sc_log() {
level=$1; shift
echo "[$level] $@"
# levels:
# DEBUG = 0
# INFO = 1
# WARN = 2
# ERROR = 3
SC_LOGGER_LEVEL=${SC_LOGGER_LEVEL:-1}
__sc_log_level_to_text() {
case $1 in
0) echo "debug" ;;
1) echo "info" ;;
2) echo "warn" ;;
3) echo "error" ;;
4) echo "fatal" ;;
esac
}
alias LOGD="__sc_log debug"
alias LOGI="__sc_log info"
alias LOGW="__sc_log warn"
alias LOGE="__sc_log error"
__sc_log() {
level=$1
shift
if [ "$level" -ge "$SC_LOGGER_LEVEL" ]; then
echo "[$(__sc_log_level_to_text $level)] $@"
fi
}
alias LOGD="__sc_log 0"
alias LOGI="__sc_log 1"
alias LOGW="__sc_log 2"
alias LOGE="__sc_log 3"
fatal_log() {
__sc_log fatal $@
__sc_log 4 $@
exit 1
}
}