Page 1 of 1

Order of entries in the log

PostPosted: Fri Apr 06, 2012 10:24 am
by Islander
I vould like to have the logs with the most recent post on top when I open the log in the Control Panel. As it is now you always have to scroll down to se the most recent entries.

Islander

Re: Order of entries in the log

PostPosted: Sun Apr 08, 2012 11:25 am
by dingetje
The lastlog command simply uses 'cat' to list the /var/messages.old and /var/messages files.
Unfortunately FREESCO doesn't have the 'tac' command which is similar to 'cat' but as the name implies lists the output in reverse order.

But not all is lost, because FREESCO does have the 'sort' command out of the box. So here's how to get the desired results:

1. login as 'root' via a shell session
2. cd /wwa/cgi
3. edit usr.cgi
4. look for 'messages'
5. Old code:
Code: Select all
log*)   ttl; $E
        cat /var/log/messages.old 2>/dev/null
        $E
        cat /var/messages
        $E
        end;;

6. New code:
Code: Select all
log*)   ttl; $E
        cat /var/messages | sort -M -r
        $E
        cat /var/log/messages.old 2>/dev/null | sort -M -r
        $E
        end;;

7. Save changes
8. Use 'Recent Log' command in Control Panel, should be in reverse order now.

Re: Order of entries in the log

PostPosted: Sun Apr 08, 2012 11:20 pm
by Lightning
Unfortunately the built in sort command in the 04x series does not support the -M flag. However the -r flag should do the job on it's own. Also the usr.cgi file is quite a bit different. So you will need these changes in the 04x series.
Old code lines 173~175
Code: Select all
inflog*)ttl;cat /var/log/infolog.old 2>/dev/null|$Fl;cat /var/infolog|$Fl;end;;
login*) ttl;cat /var/secure.old 2>/dev/null|$Fl;cat /var/secure|$Fl;end;;
log*)   ttl;cat /var/log/messages.old 2>/dev/null|$Fl;cat /var/messages|$Fl;end;;

New code lines 173~175
edit /wwa/cgi/usr.cgi
Code: Select all
inflog*)ttl;sort -r /var/log/infolog|$Fl;sort -r /var/infolog.old 2>/dev/null|$Fl;end;;
login*) ttl;sort -r /var/secure|$Fl;sort -r /var/secure.old 2>/dev/null|$Fl;end;;
log*)   ttl;sort -r /var/log/messages|sort -r|$Fl;sort -r /var/messages.old 2>/dev/null|$Fl;end;;


To make the above changes survive a reboot you will need to do the following commands as well in the 04x series
Code: Select all
mkdir /boot/cpc/cgi
cp /wwa/cgi/usr.cgi /boot/cpc/cgi/usr.cgi

Re: Order of entries in the log

PostPosted: Thu Apr 26, 2012 3:26 pm
by dingetje
As a matter of fact I do have a working tac executable for FREESCO.
It's part of the coreutils package for 03x.

If you want to experiment with it, the binary can be downloaded from here:
http://dingetje.homeip.net/downloads/tac.gz

Simply unpack in /pkg/bin and you should be able to run the 'tac' command which is similar to 'cat' but lists the text file in reverse, so last line first.