diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-06-07 11:37:28 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-06-07 11:37:28 +0300 |
commit | a06122c67a1c0de3bfa8236cbeaba2e4b2b32527 (patch) | |
tree | 6890b8cf391b36b9bb604e5b3447ecb005cee413 /lib | |
parent | 8dedceabde58a66b3b8e624bd92058ca5f33f822 (diff) | |
download | arching-kaos-tools-a06122c67a1c0de3bfa8236cbeaba2e4b2b32527.tar.gz arching-kaos-tools-a06122c67a1c0de3bfa8236cbeaba2e4b2b32527.tar.bz2 arching-kaos-tools-a06122c67a1c0de3bfa8236cbeaba2e4b2b32527.zip |
Refactoring
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/_ak_log | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/_ak_log b/lib/_ak_log index 09eb1dc..8d1e227 100755 --- a/lib/_ak_log +++ b/lib/_ak_log @@ -36,11 +36,16 @@ _ak_log_grep(){ } _ak_log_rotate(){ - tar cvfz $AK_ARCHIVESDIR/logs_$(date -u +%s).tar.gz $AK_WORKDIR/logs - tar cvfz $AK_ARCHIVESDIR/akd-logs_$(date -u +%s).tar.gz $AK_WORKDIR/akd.log - - cat /dev/null > $AK_WORKDIR/akd.log - cat /dev/null > $AK_WORKDIR/logs + if [ -f $AK_LOGSFILE ] + then + tar cvfz $AK_ARCHIVESDIR/logs_$(date -u +%s).tar.gz $AK_WORKDIR/logs + cat /dev/null > $AK_WORKDIR/logs + fi + if [ -f $AK_WORKDIR/akd.log ] + then + tar cvfz $AK_ARCHIVESDIR/akd-logs_$(date -u +%s).tar.gz $AK_WORKDIR/akd.log + cat /dev/null > $AK_WORKDIR/akd.log + fi } _ak_log_message(){ @@ -52,11 +57,10 @@ _ak_log_message(){ if [ ! -z "$3" ] && [ -n "$3" ] then echo "$TS" "<$1>" "[$2]" "$3" >> $AK_LOGSFILE - if [ "$AK_DEBUG" == "yes" ] + if [ ! -z $AK_DEBUG ] && [ -n "$AK_DEBUG" ] && [ "$AK_DEBUG" == "yes" ] then echo "$TS" "<$1>" "[$2]" "$3" >&2 fi - exit 0 else echo "$TS" "<$1>" "[ERROR]" "No message" >> $AK_LOGSFILE if [ "$AK_DEBUG" == "yes" ] @@ -84,21 +88,21 @@ _ak_log_message(){ } logit(){ - ak-log-message "$PROGRAM" "$1" "$2" + _ak_log_message "$PROGRAM" "$1" "$2" } _ak_log_warning(){ - ak-log-message "$PROGRAM" "WARNING" "$1" + _ak_log_message "$PROGRAM" "WARNING" "$1" } _ak_log_debug(){ - ak-log-message "$PROGRAM" "DEBUG" "$1" + _ak_log_message "$PROGRAM" "DEBUG" "$1" } _ak_log_error(){ - ak-log-message "$PROGRAM" "ERROR" "$1" + _ak_log_message "$PROGRAM" "ERROR" "$1" } _ak_log_info(){ - ak-log-message "$PROGRAM" "INFO" "$1" + _ak_log_message "$PROGRAM" "INFO" "$1" } |