mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Log rotation: store first 500 lines of print3d and firmware logs separately to prevent them from being rotated.
This commit is contained in:
parent
584a5bfce2
commit
00d77c491d
@ -9,5 +9,28 @@ create
|
||||
size 1000k
|
||||
missingok
|
||||
olddir /tmp/wifibox-rotated
|
||||
copytruncate
|
||||
|
||||
# as alternative to copytruncate (which *might* miss lines) we could implement
|
||||
# SIGUSR1 in print3d and firmware to reopen their logs
|
||||
copytruncate # 'create' is ignored with copytruncate, as the file stays in place
|
||||
|
||||
prerotate
|
||||
FIRST_N_LINES=500
|
||||
PRINT3D_LOGHEAD_FILE=print3d-loghead
|
||||
WIFIBOX_LOGHEAD_FILE=wifibox-loghead
|
||||
ROTATED_FILES_PATH=/tmp/wifibox-rotated
|
||||
|
||||
#Note: by looking at creation date of the print3d socket and comparing against that
|
||||
# of print3d-loghead we could detect a server restart (e.g. due to reconnected printer)
|
||||
|
||||
echo "$1" | grep -q "print3d-.*\.log"
|
||||
if [ $? -eq 0 -a ! -f "$ROTATED_FILES_PATH/$PRINT3D_LOGHEAD_FILE" ]; then
|
||||
head -q -n$FIRST_N_LINES "$1" > "$ROTATED_FILES_PATH/$PRINT3D_LOGHEAD_FILE"
|
||||
fi
|
||||
|
||||
echo "$1" | grep -q "wifibox.log"
|
||||
if [ $? -eq 0 -a ! -f "$ROTATED_FILES_PATH/$WIFIBOX_LOGHEAD_FILE" ]; then
|
||||
head -q -n$FIRST_N_LINES "$1" > "$ROTATED_FILES_PATH/$WIFIBOX_LOGHEAD_FILE"
|
||||
fi
|
||||
endscript
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user