aboutsummaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2019-04-08 06:32:25 +0000
committerArne Juul <arnej@yahoo-inc.com>2019-04-08 06:55:39 +0000
commit464518bdd46dc109af35f8a4d2f4ee432cb4cf56 (patch)
tree1c2ea3d16943055fac42084d9cef14c51c47fb69 /logd
parent26be1d5ef63aa915204696a7ffc00e0f672615d3 (diff)
produce less debug logs from retention enforcer
Diffstat (limited to 'logd')
-rwxr-xr-xlogd/src/apps/retention/retention-enforcer.sh19
1 files changed, 12 insertions, 7 deletions
diff --git a/logd/src/apps/retention/retention-enforcer.sh b/logd/src/apps/retention/retention-enforcer.sh
index d1defacd4e3..a8f3730f4ce 100755
--- a/logd/src/apps/retention/retention-enforcer.sh
+++ b/logd/src/apps/retention/retention-enforcer.sh
@@ -15,11 +15,15 @@ RETAIN_DAYS=30
# The "database" holds lines with format "timestamp /path/to/logfile"
# where "timestamp" is just seconds since epoch.
+log_msg() {
+ echo "$0 [$$]" "$@"
+}
+
prereq_dir() {
if [ -d $1 ] && [ -w $1 ]; then
:
else
- echo "$0: missing directory '$1' in '`pwd`'" >&2
+ log_msg ERROR "missing directory '$1' in '`pwd`'" >&2
exit 1
fi
}
@@ -33,13 +37,14 @@ ensure_dir () {
if [ -d $1 ] && [ -w $1 ]; then
return 0
fi
- echo "Creating directory '$1' in '`pwd`'"
+ log_msg INFO "Creating directory '$1' in '`pwd`'"
mkdir -p $1 || exit 1
}
prepare_stuff() {
check_prereqs
- exec > $DBGF.$$.log 2>&1
+ ensure_dir ${DBGF%/*}
+ exec >> $DBGF.log 2>&1
ensure_dir $DBDIR
}
@@ -68,7 +73,7 @@ check_pidfile() {
ps -p $pid >/dev/null 2>&1 || return 1
proc=$(ps -p $pid 2>&1)
case $proc in *retention*) ;; *) return 1;; esac
- echo "$0 [$$]: Yielding my place to pid '$pid'"
+ log_msg INFO "Yielding my place to pid '$pid'"
exit 1
fi
}
@@ -82,7 +87,7 @@ maybe_collect() {
logfilename=$2
if bad_timestamp "$1"; then
- echo "WARNING: bad timestamp '$timestamp' for logfilename '$logfilename'"
+ log_msg WARNING "bad timestamp '$timestamp' for logfilename '$logfilename'"
return
fi
@@ -92,7 +97,7 @@ maybe_collect() {
lim2=$(($mod_time + $add))
if [ $lim1 -lt $now ] && [ $lim2 -lt $now ]; then
- echo "Collect logfile '$logfilename' timestamped $timestamp modified $mod_time"
+ log_msg INFO "Collect logfile '$logfilename' timestamped $timestamp modified $mod_time"
rm -f "$logfilename"
fi
}
@@ -124,10 +129,10 @@ process_all() {
mainloop() {
while true; do
+ check_pidfile
mark_pid
process_all
sleep 3600
- check_pidfile
done
}