#!/bin/sh # 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 } __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 4 $@ exit 1 }