Updated log function/bash (default values) + use in update

This commit is contained in:
xdrm-brackets 2017-01-30 10:54:57 +01:00
parent d4b14c1d02
commit 390312ad41
2 changed files with 10 additions and 2 deletions

View File

@ -27,6 +27,14 @@ syscall(){
# $3 - flag
slog(){
echo $(date +%s)." [$2] $1" >> $LOG_DIR."/$3.log";
test -z "$1" && msg="unknown error" || msg="$1";
test -z "$2" && feature="main" || feature="$2";
test -z "$3" && flag="daemon" || flag="$3";
test "$msg" = "-" && msg="unknown error" || msg="$1";
test "$feature" = "-" && feature="main" || feature="$2";
test "$flag" = "-" && flag="daemon" || flag="$3";
echo "$(date +%s) [$feature] $msg" >> $LOG_DIR/$flag.log;
}

2
update
View File

@ -6,7 +6,7 @@ source $__DIR__/lib/include/bash/const;
source $__DIR__/lib/include/bash/func;
# [1] Send data + fetch configuration
$SOURCE_DIR/lib/api/sync;
test $($SOURCE_DIR/lib/api/sync) -eq 127 && slog "sync failed" - "update" && exit;
test $? -ne 0 && exit 127;