Jonathan Hart

Added -l option to onos-log to use less on the log instead of tail

Change-Id: Ib6aaa5c12b85483eb3e2ec021b6daceb40994b6c
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
6 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 6 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 . $ONOS_ROOT/tools/build/envDefaults 7 . $ONOS_ROOT/tools/build/envDefaults
8 8
9 +less=0
10 +
11 +[ "$1" = "-l" ] && shift && less=1
12 +
9 remote=$ONOS_USER@${1:-$OCI} 13 remote=$ONOS_USER@${1:-$OCI}
10 instance=$2 14 instance=$2
11 15
...@@ -15,10 +19,14 @@ instance=$2 ...@@ -15,10 +19,14 @@ instance=$2
15 19
16 trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | xargs kill'" EXIT 20 trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | xargs kill'" EXIT
17 21
18 -ssh $remote " 22 +if [ $less -eq 1 ]; then
23 + ssh -t $remote "less $LOG"
24 +else
25 + ssh $remote "
19 while true; do 26 while true; do
20 echo ================================================================== 27 echo ==================================================================
21 [ ! -f $LOG ] && sleep 2 && continue 28 [ ! -f $LOG ] && sleep 2 && continue
22 tail -n 512 --follow=name $LOG --sleep-interval 2 29 tail -n 512 --follow=name $LOG --sleep-interval 2
23 done 30 done
24 -" 31 + "
32 +fi
......