Start logging level mechanism
This commit is contained in:
parent
5a5eed8c7c
commit
07fafbfa89
37
git-build.sh
37
git-build.sh
|
@ -8,14 +8,49 @@
|
|||
|
||||
BASEDIR="$HOME/.git-build"
|
||||
|
||||
# Default logging levels (error is always enabled)
|
||||
INFO=1
|
||||
DEBUG=0
|
||||
|
||||
# We set custom logging functions so that later we can decorate stuff
|
||||
warn() {
|
||||
echo -e "\e[33mWARNING:\e[0m $@" > /dev/stderr
|
||||
}
|
||||
|
||||
info() {
|
||||
echo "[git-build] $@"
|
||||
}
|
||||
|
||||
error () {
|
||||
echo -e "\e[31mERROR:\e[0m $@" > /dev/stderr
|
||||
}
|
||||
|
||||
# Logging is done with the LOG="debug|info|error" environment variable
|
||||
if [ ! -z $LOG ] && [ "$LOG" != "" ]; then
|
||||
case $LOG in
|
||||
"debug"|"DEBUG")
|
||||
DEBUG=1
|
||||
;;
|
||||
"error"|"ERROR")
|
||||
INFO=0
|
||||
;;
|
||||
"info"|"INFO")
|
||||
;;
|
||||
*)
|
||||
warn "\$LOG is \"$LOG\" which is not understood to be a logging level."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
run() {
|
||||
p_name="$1"
|
||||
echo "[$p_name] RUN"
|
||||
info "[$p_name] RUN"
|
||||
# Run in background and redirect output to $p_name.log
|
||||
(GITBUILDCONF="$CONFDIR" GITBUILDDIR="$BASEDIR" nohup $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2> $BASEDIR/$p_name.err) &
|
||||
}
|
||||
|
||||
# So scripts can know we're still running (for autoupdater)
|
||||
# TODO needs to be reworked so multiple instances can run at the same time
|
||||
touch $BASEDIR/.LOCK
|
||||
|
||||
# Overriden by -f/--force to force rebuild when no update is available
|
||||
|
|
Loading…
Reference in New Issue