aboutsummaryrefslogtreecommitdiff
path: root/lib/_ak_log
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-06-07 11:37:28 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-06-07 11:37:28 +0300
commita06122c67a1c0de3bfa8236cbeaba2e4b2b32527 (patch)
tree6890b8cf391b36b9bb604e5b3447ecb005cee413 /lib/_ak_log
parent8dedceabde58a66b3b8e624bd92058ca5f33f822 (diff)
downloadarching-kaos-tools-a06122c67a1c0de3bfa8236cbeaba2e4b2b32527.tar.gz
arching-kaos-tools-a06122c67a1c0de3bfa8236cbeaba2e4b2b32527.tar.bz2
arching-kaos-tools-a06122c67a1c0de3bfa8236cbeaba2e4b2b32527.zip
Refactoring
Diffstat (limited to 'lib/_ak_log')
-rwxr-xr-xlib/_ak_log28
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"
}