]> git.donarmstrong.com Git - bin.git/blob - logview
add joeyh's logview
[bin.git] / logview
1 #!/usr/bin/perl
2 # Log viewer program. Pass it parameters of the logs to view, or it will 
3 # automatically view some.
4
5 $|=1;
6
7 $logdir='/var/log';
8 @logfiles=@ARGV;
9
10 # If I am root, look at all logs, otherwise only those that are
11 # world-readable.
12 my $perm='';
13 $perm='-perm +6' if $? != 0;
14 if (! @logfiles) {
15         @logfiles=split /\n/, `find $logdir -type f -regex '.*.log' ! -name faillog ! -name lastlog $perm`;
16         push @logfiles, "$logdir/mail.err", "$logdir/mail.warn";
17 }
18
19 if (-e $ENV{HOME}."/.xsession-errors") {
20         push @logfiles, $ENV{HOME}."/.xsession-errors";
21 }
22
23 # Tail without wasting the last line of the screen.
24 open(TAIL, "tail -q --follow=name --retry -n 2 @logfiles|");
25 while (<TAIL>) {
26         print "\n";
27         chomp;
28         print $_;
29 }