aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"
}