Release new version 2.13.0
[grml-scripts.git] / usr_bin / logview
1 #!/usr/bin/perl
2 # Filename:      logview
3 # Purpose:       Log viewer program. Pass it parameters of the logs to view, or it will automatically view some.
4 # Authors:       Joey Hess <joey@kitenet.net>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       Unknown (origin: see http://svn.kitenet.net/trunk/bin/logview)
7 ################################################################################
8
9 $|=1;
10
11 $logdir='/var/log';
12 @logfiles=@ARGV;
13
14 # If I am root, look at all logs, otherwise only those that are
15 # world-readable.
16 my $perm='';
17 $perm='-perm +6' if $? != 0;
18 if (! @logfiles) {
19         @logfiles=split /\n/, `find $logdir -type f -regex '.*.log' ! -name faillog ! -name lastlog $perm`;
20         push @logfiles, "$logdir/mail.err", "$logdir/mail.warn";
21 }
22
23 if (-e $ENV{HOME}."/.xsession-errors") {
24         push @logfiles, $ENV{HOME}."/.xsession-errors";
25 }
26
27 # Tail without wasting the last line of the screen.
28 open(TAIL, "tail -q --follow=name --retry -n 2 @logfiles|");
29 while (<TAIL>) {
30         print "\n";
31         chomp;
32         print $_;
33 }
34
35 ## END OF FILE #################################################################