From 390312ad415e070333aeb020fc39185a3c0f07e1 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 30 Jan 2017 10:54:57 +0100 Subject: [PATCH] Updated log function/bash (default values) + use in update --- lib/include/bash/func | 10 +++++++++- update | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/include/bash/func b/lib/include/bash/func index ef8fd24..117ca15 100755 --- a/lib/include/bash/func +++ b/lib/include/bash/func @@ -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; } diff --git a/update b/update index cbcff81..c05b121 100755 --- a/update +++ b/update @@ -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;