hbbs

bbs.hlirc.net
Log | Files | Refs | README | LICENSE

commit a1edc950eef66cc6a132a1054d623f093f83c148
parent c4948faa242bd4f644635471dfe43a38bfd527c5
Author: hhvn <hayden@haydenvh.com>
Date:   Sat, 27 Feb 2021 02:31:05 +0000

include/log.sh: archive old log entries

Diffstat:
Minclude/log.sh | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/log.sh b/include/log.sh @@ -4,7 +4,11 @@ add_log(){ lock $datadir/log/log - awk -v "date=$(date +%Y-%d-%m)" -v "time=$(date +%H:%M)" -v "key=$1" -v "value=$2" -F" " ' + awk -v "datadir=$datadir" -v "date=$(date +%Y-%d-%m)" -v "time=$(date +%H:%M)" -v "key=$1" -v "value=$2" -F" " ' + $1 != date { + print $0 > datadir"/log/"$1".archive" + # archive old log entries + } $1 == date # only keep logs from today END {printf("%s\t%s\t%s\t%s", date, time, key, value)} ' < $datadir/log/log > $datadir/log/log.new