Skip to content

Commit b4e394d

Browse files
committed
Enhance log tailing options and cleanup functionality
1 parent f06c62b commit b4e394d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

codjixd.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,31 @@ show_status() {
126126

127127
# Tail the logs of a service
128128
tail_logs() {
129-
# read option: .log or .old.log
130129
echo "[o] Tailing logs for service: $SERVICE_NAME"
131130
echo '[o] Press "h" to show help, "q" to stop it'
132131
echo -e '[o] Press "F" for live logs, "CTRL + C" to stop it\n'
133132
echo "1. Current run logs"
134133
echo "2. Old history logs"
135-
echo "3. Cancel"
134+
echo "3. Live logs"
135+
echo "4. Clean up logs"
136+
echo "0. Cancel"
136137
read -p "Choose an option [1]: " option
137138
option="${option:-1}"
139+
args=""
138140
case "$option" in
141+
0) return 0 ;;
139142
1) option="$LOG_FILE.log" ;;
140143
2) option="$LOG_FILE.old.log" ;;
141-
3) return 0 ;;
144+
3) option="$LOG_FILE.log" && args="+F" ;;
145+
4) rm -f $LOG_FILE.{log,old.log} > /dev/null && \
146+
echo "[o] Done" && exit 0 ;;
142147
*) echo "[x] Invalid option: $option" && return 1 ;;
143148
esac
144149
if [ ! -f "$option" ]; then
145150
echo "[x] No logs for $SERVICE_NAME."
146151
return 1
147152
fi
148-
less -M "$option"
153+
less -M $args "$option"
149154
}
150155

151156
# List all available services

0 commit comments

Comments
 (0)